Nginx平滑升级

1、源码包下载:http://nginx.org/en/download.html (nginx-1.20.2.tar.gz)

 

2、查看旧版本安装模块:

nginx -V
nginx version: nginx/1.18.0
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 --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-pcre

3、编译不安装

复制代码
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-pcre

make
注:make后会生成一个objs文件夹

[root@k8s-master nginx-1.23.1]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@k8s-master nginx-1.23.1]#

复制代码

4、替换二进制文件

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp /root/nginx-1.23.1/objs/nginx /usr/local/sbin/

5、平滑升级

复制代码
cd /usr/local/nginx/sbin/
./nginx -V #检查当前版本
nginx version: nginx/1.23.1
./nginx -t #检查nginx配置文件
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
#查看nginx进程信息
ps -ef|grep nginx
#删除旧版本的nginx进程信息
kill -USR2 PID【旧版本Nginx主进程号】
#发送WINCH信号给旧的主进程。然后,他的工作进程将从容关闭
kill -WINCH PID【旧版本的Nginx主进程号】
#删除nginx旧主进程
kill -QUIT PID【旧主进程号】
复制代码

 6、如果多台相同环境的nginx需要升级,只需要将nginx二进制文件传到对应的/usr/local/nginx/sbin/下,执行平滑升级过程就可以了。

posted @   Memory-  阅读(157)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示