一、下载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```
END

本文标题:Nginx源码包平滑升级1.20

本文作者:风度翩翩小公子

本文链接:https://lolicp.com/linux/202114280.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归 (lolicp.com) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2024 年 10 月 05 日
如果觉得我的文章对你有用,请随意赞赏