Linux下平滑升级nginx
一、升级前准备
1.对nginx的配置文件nginx.conf做备份;
2.新建目录/root/nginx,将安装包和脚本上传到该目录下;
二、平滑升级nginx
1.开始编译新版本的nginx
cd /root/nginx
tar -xf nginx-1.10.3.tar.gz
cd nginx-1.10.3
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module&&make
2.开始重命名旧版本nginx的可执行文件,替换新版本nginx的可执行文件
cd /usr/local/nginx/sbin
mv nginx nginx.old
cp -r /root/nginx/nginx-1.10.3/objs/nginx .
3.检查nginx配置文件的正确性
/usr/local/nginx/sbin/nginx -t
4.开始升级新版nginx
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
5.旧版本nginx的pid变成nginx.pid.oldbin
cd /usr/local/nginx/logs
ls -lrt nginx.pid.oldbin
6.关闭旧版本nginx
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
7.查看新版nginx的版本号
/usr/local/nginx/sbin/nginx -v