1. 查看原程序的编译参数
[root@node2 ~]# nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/share/nginx/nginx1.16.1 --with-http_ssl_module --with-http_stub_status_module
2. 备份
[root@node2 ~]# cd /share/nginx/
[root@node2 nginx]# ls
nginx
[root@node2 nginx]# cp -rp nginx nginx-bak
3.下载
[root@node2 soft]# wget http://nginx.org/download/nginx-1.17.8.tar.gz
[root@node2 soft]# tar xvf nginx-1.17.8.tar.gz
[root@node2 soft]# cd nginx-1.17.8
#不make install
[root@node2 nginx-1.17.8]# ./configure --prefix=/share/nginx/nginx --with-http_ssl_module --with-http_stub_status_module && make
4.编译覆盖
复制编译make后的文件nginx,覆盖正在执行的原来的nginx文件
[root@node2 nginx-1.17.8]# pwd
/share/soft/nginx-1.17.8
[root@node2 nginx-1.17.8]# cd objs/
[root@node2 objs]# ls
autoconf.err Makefile nginx nginx.8 ngx_auto_config.h ngx_auto_headers.h ngx_modules.c ngx_modules.o src
[root@node2 objs]# cp nginx /share/nginx/nginx/
client_body_temp/ fastcgi_temp/ logs/ sbin/ uwsgi_temp/
conf/ html/ proxy_temp/ scgi_temp/
[root@node2 objs]# cp nginx /share/nginx/nginx/sbin/nginx
cp: overwrite ‘/share/nginx/nginx/sbin/nginx’? y
5.新旧交替
使旧版nginx停止就收请求,新版nginx接替
[root@node2 nginx]# pwd
/share/nginx/nginx
[root@node2 nginx]# find . -iname *.pid
./logs/nginx.pid
[root@node2 nginx]# kill -USR2 `cat ./logs/nginx.pid`
[root@node2 nginx]# nginx -t
nginx: the configuration file /share/nginx/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /share/nginx/nginx/conf/nginx.conf test is successful
[root@node2 nginx]# nginx -s reload
————Blueicex 2020/2/27 17:29 blueice1980@126.com