nginx平滑升级添加模块

悠悠 2022-04-11 12:56 402阅读 0赞

添加—with-http_realip_module

不用停止服务,平滑升级,老的nginx进程处理完所有请求后退出,新的nginx进程处理新的请求

备份nginx

cp /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx20160217

cp /opt/nginx/conf/nginx.conf /opt/nginx/conf/nginx20160217.conf

查看已安装模块

/opt/nginx/sbin/nginx -V

  1. --prefix=/opt/nginx --with-http\_stub\_status\_module --with-http\_ssl\_module

安装nginx

cd /opt/nginx-1.8.1

tar zxvf nginx-1.8.1_ssi.tar.gz

cd nginx-1.8.1

./configure —prefix=/opt/nginx —with-http_stub_status_module —with-http_ssl_module —with-http_realip_module

make

(注意不是make install)

备份nginx为nginx.old

\cp -rf /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx.old

拷贝新的nginx

\cp -rf /opt/nginx-1.8.1/nginx-1.8.1/objs/nginx /opt/nginx/sbin/nginx

升级

make upgrade

  1. /opt/nginx/sbin/nginx -t
  2. nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
  3. nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
  4. kill -USR2 \`cat /opt/nginx/logs/nginx.pid\`
  5. sleep 1
  6. test -f /opt/nginx/logs/nginx.pid.oldbin
  7. kill -QUIT \`cat /opt/nginx/logs/nginx.pid.oldbin\`

查看已安装模块

/opt/nginx/sbin/nginx -V

  1. --prefix=/opt/nginx --with-http\_stub\_status\_module --with-http\_ssl\_module --with-http\_realip\_module

上传新的nginx.conf至/opt/nginx/conf

/opt/nginx/sbin/nginx -t

/opt/nginx/sbin/nginx -s reload

如果可以重启

/opt/nginx/sbin/nginx -t

/opt/nginx/sbin/nginx -s reload

/opt/nginx/sbin/nginx -s quit

#/opt/nginx/sbin/nginx -s stop

/opt/nginx/sbin/nginx &

发表评论

表情:
评论列表 (有 0 条评论,402人围观)

还没有评论,来说两句吧...

相关阅读

    相关 nginx平滑升级

    1、为什么要对 nginx 平滑升级 随着 `nginx` 越来越流行,并且 `nginx` 的优势也越来越明显,`nginx` 的版本迭代也来时加速模式,1.9.0版本

    相关 Nginx平滑升级

    一、环境准备 在业务不关闭情况下进行升级,并且不要版本差距太大,不然很多东西不支持容易崩溃 环境:centos7.3一台 版本:旧的1.8,新的1.10 部署目