一.编译参数
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --add-module=/opt/nginx/nginx-upsync --add-module=/opt/nginx/echo-nginx-module-0.61 --add-module=/opt/nginx/ngx_devel_kit-0.3.0 --add-module=/opt/nginx/lua-nginx-module-0.10.9rc7 --with-stream
参数解析:
--prefix=/usr/local/nginx
:指的是工作根目录,当编译跟安装完了之后,nginx的工作子目录以及文件会自动生成在根目录下面。
--with-http_ssl_module
:http的一个支持模块,nginx自带的,但是需要手动开启。
--with-http_flv_module
: 提供服务端伪流媒体支持,nginx自代的,需要手动开启。
--with-http_stub_status_module
:nginx的统计模块,nginx自代的,需要手动开启。
--with-http_gzip_static_module
: 扩展压缩模块,nginx自代的,需要手动开启。
--with-http_realip_module
:获取真实IP模块,nginx自代的,需要手动开启。
--add-module=/opt/nginx/nginx-upsync
:nginx-upsync模块,里面包含了nginx-stream-upsync-module模块跟nginx-upsync-module模块,nginx-stream-upsync-module是支持在stream模块里面,给tcp/udp连接提供动态加载upstream配置的模块;而nginx-upsync-module模块是支持在http模块里面,给http请求提供动态加载upstream配置的模块。我这里是把两个模块合并到一起了,然后统一使用nginx-upsync模块添加到nginx中。
(合并过程写到后面)
--add-module=/opt/nginx/echo-nginx-module-0.61
:echo模块,可以在nginx中直接使用 echo 函数输出字符串返回给请求端。
--add-module=/opt/nginx/ngx_devel_kit-0.3.0
:ngx_devel_kit是一个拓展nginx服务器核心功能的模块,第三方模块开发可以基于它来快速实现。NDK提供函数和宏处理一些基本任务,减轻第三方模块开发的代码量。这里就是用来配合lua模块使用的。
--add-module=/opt/nginx/lua-nginx-module-0.10.9rc7
:lua模块,支持在ngxin中使用lua脚本,很强大。
--with-stream
:开启stream模块,让ngxin支持tcp/udp的代理。
二.合并nginx-upsync
模块过程
1.下载源文件
git clone https://github.com/CallMeFoxie/nginx-upsync.git
cd nginx-upsync
git clone https://github.com/xiaokai-wang/nginx-stream-upsync-module.git
git clone https://github.com/weibocom/nginx-upsync-module.git
好像这样就合并完了。。。如果过程中提示冲突或者是否覆盖什么的,直接覆盖就完事儿了。nginx-upsync的路径就是上面--add-module=/opt/nginx/nginx-upsync
中的路径。