Nginx服务平滑升级

//最新的nginx的安装包
[root@localhost ~]# ls
anaconda-ks.cfg  nginx-1.20.2  nginx-1.20.2.tar.gz
[root@localhost ~]# 
[root@localhost ~]# wget http://nginx.org/download/nginx-1.22.0.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg  nginx-1.20.2  nginx-1.20.2.tar.gz  nginx-1.22.0.tar.gz
[root@localhost ~]# 

//下载git包
[root@localhost ~]# yum -y install git

//下载nginx更新安装包
[root@localhost ~]# git clone https://gitee.com/wujunze/nginx_module_echo.git
Cloning into 'nginx_module_echo'...
remote: Enumerating objects: 80, done.
remote: Total 80 (delta 0), reused 0 (delta 0), pack-reused 80
Receiving objects: 100% (80/80), 14.34 KiB | 1.43 MiB/s, done.
Resolving deltas: 100% (37/37), done.
[root@localhost ~]# ls
anaconda-ks.cfg  nginx-1.20.2.tar.gz  nginx_module_echo
nginx-1.20.2     nginx-1.22.0.tar.gz
[root@localhost ~]# 


//添加新的功能

[root@localhost ~]# cd nginx-1.22.0/
[root@localhost nginx-1.22.0]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@localhost nginx-1.22.0]# ./configure --help
--add-module=PATH                  enable external module
里面有添加新的模块的功能


[root@localhost nginx-1.22.0]# ./configure  --prefix=/usr/local/nginx --user=nginx --group=nginx 
--with-debug --with-http_ssl_module 
--with-http_realip_module --with-http_image_filter_module
--with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=../nginx_module_echo

[root@localhost nginx-1.22.0]# make -j $(grep 'processor' /proc/cpuinfo | wc -l)
[root@localhost nginx-1.22.0]# ls
auto     CHANGES.ru  configure  html     Makefile  objs    src
CHANGES  conf        contrib    LICENSE  man       README
[root@localhost nginx-1.22.0]# objs/nginx -v
nginx version: nginx/1.22.0
[root@localhost nginx-1.22.0]# 
[root@localhost nginx-1.22.0]# du -sh objs/nginx
6.0M	objs/nginx
[root@localhost nginx-1.22.0]# 

平滑升级过程:
获取老版本的编译信息
获取新版本安装包或功能包
配置新版本或功能,配置时加上老版本的编译信息和新版本或功能(--add-module)
编译,编译完后不能执行安装操作备份老版本程序,使用复制的方式
停掉老版本程序的进程
将新版本程序复制到老版本所在位置替换掉老版本启动新版本

[root@localhost nginx-1.22.0]# cp /usr/local/nginx/sbin/nginx{,-bak};pkill nginx;cp objs/nginx /usr/local/nginx/sbin/nginx;systemctl start nginx
cp: overwrite '/usr/local/nginx/sbin/nginx-bak'? y
cp: overwrite '/usr/local/nginx/sbin/nginx'? y
[root@localhost nginx-1.22.0]# 
[root@localhost nginx-1.22.0]# nginx -v
nginx version: nginx/1.22.0
[root@localhost nginx-1.22.0]# 
[root@localhost ~]# ss -anlt
State    Recv-Q   Send-Q       Local Address:Port       Peer Address:Port   Process   
LISTEN   0        128                0.0.0.0:80              0.0.0.0:*                
LISTEN   0        128        192.168.119.157:8081            0.0.0.0:*                
LISTEN   0        128                0.0.0.0:22              0.0.0.0:*                
LISTEN   0        128                   [::]:22                 [::]:*                
[root@localhost ~]# 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值