查看现有nginx的编译参数:
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# nginx -V
nginx version: nginx/1.12.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
built with OpenSSL 1.0.2l 25 May 2017
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-openssl=/root/lnmp1.4/src/openssl-1.0.2l --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
查看所需模块名字:
原有nginx编译目录:
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# cd /nginx-1.12.2
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# ./configure --help | grep proxy
--without-http_proxy_module disable ngx_http_proxy_module
重新编译模块参数:
./configure --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-openssl=/root/lnmp1.4/src/openssl-1.0.2l
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# make
替换nginx二进制文件:
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# which nginx
/usr/bin/nginx
可以看到是一个软连接:
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# ll /usr/bin/nginx
lrwxrwxrwx 1 root root 27 May 7 2018 /usr/bin/nginx -> /usr/local/nginx/sbin/nginx
停止nginx:
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# nginx -s stop
[root@iZbp1d0dkjhfmxnxp7wuhmZ nginx-1.12.2]# cp objs/nginx /usr/local/nginx/sbin/nginx
启动nginx: