nginx平滑添加模块

因APP开发ios需要,需要nginx支持ipv6,然而线上服务器nginx为编译安装,现记录下,nginx如何平滑添加模块

1、先查看nginx版本和已支持的模块,发现未有--with-ipv6模块

[root@bogon sbin]# ./nginx -V
nginx version: nginx/1.11.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --error-log-path=/var/log/nginx-err --http-log-path=/usr/local/nginx/logs --user=nginx --group=nginx --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_gzip_static_module --with-http_perl_module --with-pcre --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-stream --with-stream_ssl_module --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-http_realip_module --with-http_v2_module --with-http_addition_module --with-http_image_filter_module --with-http_secure_link_module --add-module=/usr/local/ngx_devel_kit-0.3.0 --add-module=/usr/local/lua-nginx-module-0.10.6

2、官网下载相同版本nginx

3、添加模块

下载要添加的模块,如果是第三方则需要下载,然后指定添加路径(就是下载第三方的路径),以淘宝ngx_http_concat_module模块为列 --add-module=/home/xiexie/nginx-http-concat ,如果是自带的模块比如我们今天要添加的ipv6模块 --with-ipv6

编译前加上之前查看版本的模块信息

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs --user=nginx --group=nginx --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_gzip_static_module --with-http_perl_module --with-pcre --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-stream --with-stream_ssl_module --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-http_realip_module --with-http_v2_module --with-http_addition_module --with-ipv6 --with-http_image_filter_module --with-http_secure_link_module --add-module=/usr/local/ngx_devel_kit-0.3.0 --add-module=/usr/local/lua-nginx-module-0.10.6

编译成功后make,记住千万不要make install,这样会覆盖你以前的nginx

这时先结束掉nginx进程

ps -ef | grep nginx | grep -v grep | awk '{print $2}' | xargs kill -9

备份nginx 

mv /usr/local/nginx /usr/local/nginx.bak

复制编译目录下的nginx启动文件

cp ./objs/nginx /usr/local/nginx/sbin/

4、启动测试

[root@bogon sbin]# ./nginx -V
nginx version: nginx/1.11.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --error-log-path=/var/log/nginx-err --http-log-path=/usr/local/nginx/logs --user=nginx --group=nginx --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_gzip_static_module --with-http_perl_module --with-pcre --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-stream --with-stream_ssl_module --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-http_realip_module --with-http_v2_module --with-http_addition_module --with-http_image_filter_module --with-http_secure_link_module --with-ipv6 --add-module=/usr/local/ngx_devel_kit-0.3.0 --add-module=/usr/local/lua-nginx-module-0.10.6

猜你喜欢

转载自blog.csdn.net/ziwuzhulin/article/details/80708906
今日推荐