nginx平滑升级

官网下载最新的安装版

下载地址
https://nginx.org/en/download.html
image

将下载的包上传到服务器后进行更新操作

解压

tar xf nginx-1.27.0.tar.gz -C /usr/src

查看当前nginx配置参数

nginx -v

nginx version: nginx/1.24.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_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_realip_module --with-stream_ssl_module

在新版本中进行编译

cd /usr/src/nginx-1.27.0/ && ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_realip_module --with-stream_ssl_module

make

无需make install

对原来的nginx进行备份

where nginx
cd /usr/local/nginx/sbin
mv nginx nginx-1.24.0old
cd /usr/src/nginx-1.27.0/objs
cp ./nginx /usr/local/nginx/sbin/
nginx -V

nginx version: nginx/1.27.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_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_realip_module --with-stream_ssl_module

进行平滑升级替换

ps aux|grep nginx
可看到当前有一个master进程
发送信号给老版本进程

kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`

然后平滑关闭老进程

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