一、下载nginx源码包
Nginx官网http://nginx.org/en/download.html
二、开始平滑升级
1. 解压nginx源码包
[root@node3 tmp]# tar xf nginx-1.20.1.tar.gz
[root@node3 tmp]# cd nginx-1.20.1/
2. 查看老版本nginx的配置
[root@node3 sbin]# ./nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
3. 编译新版本nginx
[root@node3 nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
[root@node3 nginx-1.20.1]# make ## 不需要make install
4. 备份旧版本nginx
[root@node3 sbin]# cp -r `ls /usr/local/nginx | grep -v logs | xargs` /tmp/data/nginx-2021-10-12.bak/
[root@node3 nginx-1.20.1]# mv /usr/local/nginx/sbin/nginx{,.old}
5. 拷贝新版本的nginx
[root@node3 nginx-1.20.1]# cp ./objs/nginx /usr/local/nginx/sbin/
6. 执行平滑升级命令
[root@node3 nginx-1.20.1]# make upgrade
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
没报错就是安装成功
7. 查看nginx版本号
[root@node3 sbin]# ./nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module```