nginx得平滑升级
首先要查看当时编译的参数
[root@localhost ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.14.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
#####以下为对新版本进行操作编译
上传你要升级的版本包(我这里是1.14变成1.9)
[root@localhost ~]# tar -xf nginx-1.9.4.tar.gz
[root@localhost nginx-1.9.4]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module #####一定要和之前编译的相同
[root@localhost nginx-1.9.4]# make #只需make,不需make install
[root@localhost nginx-1.9.4]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old vvvvvvvvv修改默认的nginx启动脚本
[root@localhost nginx-1.9.4]# cp objs/nginx /usr/local/nginx/sbin/nginx vvvvvvvvv移动新版本的启动脚本到nginx目录
[root@localhost nginx-1.9.4]# /usr/local/nginx/sbin/nginx -t ####检查配置文件是否正确
[root@localhost nginx-1.9.4]# kill -USR2 cat /usr/local/nginx/logs/nginx.pid
vvvvvvvvv让nginx的pid改成nginx.pid.oldbin,并生成新的pid.
[root@localhost nginx-1.9.4]# cd /usr/local/nginx/logs/
[root@localhost logs]# ll
总用量 16
-rw-r–r--. 1 root root 3814 11月 26 18:34 access.log
-rw-r–r--. 1 root root 2001 11月 26 18:56 error.log
-rw-r–r--. 1 root root 6 11月 26 18:56 nginx.pid
-rw-r–r--. 1 root root 6 11月 26 17:54 nginx.pid.oldbin #####查看是否生成新的PID文件
[root@kzkt-02 logs]# kill -QUIT cat /usr/local/nginx/logs/nginx.pid.oldbin
vvvvvvvvv杀死老的nginx进程
[root@localhost logs]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.4
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
vvvvvvvvv查看新的nginx版本号
升级成功!