Nginx升级
(1)获取旧版本Nginx 的 configure 选项;
[root@localhost nginx]# sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
(2)下载新版本Nginx 源码包,对新版本的 Nginx源码包进行预编译、编译。
[root@localhost src]# wget -c nginx.org/download/nginx-1.16.0.tar.gz #没有wget命令可以通过yum安装 (yum install wget -y)
[root@localhost src]# tar xf nginx-1.16.0.tar.gz
[root@localhost src]# cd nginx-1.16.0
[root@localhost nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
[root@localhost nginx-1.16.0]# make
(3)重命名旧版本nginx 的执行文件
[root@localhost nginx-1.16.0]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
(4)复制新版本Nginx 的执行文件
[root@localhost nginx-1.16.0]# cp objs/nginx /usr/local/nginx/sbin/nginx
(5)平滑生效可执行文件
[root@localhost nginx-1.16.0]# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
#USR2参数:在老的进程号的基础之上启动新的进程。
(6)正常关闭老进程
[root@localhost nginx-1.16.0]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
(7)查看Nginx 版本
[root@localhost nginx-1.16.0]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.16.0