nginx1.6.3版本平滑升级新版本1.9.7

首先查看现在环境nginx的版本为1.6.3 以及现在的编译参数

[root@localhost ~]# nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
TLS SNI support enabled
configure arguments: –prefix=/usr/local/nginx-1.6.3 –user=nginx –group=nginx –with-http_ssl_module –with-http_gzip_static_module –with-http_gunzip_module –with-http_stub_status_module –with-pcre

平滑升级步骤如下:

下载nginx1.9.7版本,解压并进入解压后的目录

[root@localhost ~]# cd /opt/src/
[root@localhost src]# tar zxf nginx-1.9.7.tar.gz
[root@localhost src]# cd nginx-1.9.7

编译安装之前查看nginx进程ID信息:

[root@localhost nginx-1.9.7]# ps -lef | grep nginx
1 S root 1200 1 0 80 0 - 11217 rt_sig 17:15 ? 00:00:00 nginx: master process /usr/local/nginx-1.6.3/sbin/nginx -c /usr/local/nginx-1.6.3/conf/nginx.conf
5 S nginx 1203 1200 0 80 0 - 11330 ep_pol 17:15 ? 00:00:00 nginx: worker process

重新编译nginx:

./configure –prefix=/usr/local/nginx-1.6.3 –user=nginx –group=nginx –with-http_ssl_module –with-http_gzip_static_module –with-http_gunzip_module –with-http_stub_status_module –with-pcre

编译安装后可以echo $?查看是否成功,成功后只需要执行make,不需要make install;

[root@localhost nginx-1.9.7]# make

平滑升级,先移走现有的nginx二进制文件

[root@localhost nginx-1.9.7]# mv /usr/local/nginx-1.6.3/sbin/nginx  /usr/local/nginx-1.6.3/sbin/nginx.old

拷贝新生成的nginx二进制文件到指定目录

[root@localhost nginx-1.9.7]# cp objs/nginx /usr/local/nginx-1.6.3/sbin/nginx

执行升级命令

[root@localhost nginx-1.9.7]# make upgrade
/usr/local/nginx-1.6.3/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.6.3/conf/nginx.conf test is successful
kill -USR2 cat /usr/local/nginx-1.6.3/logs/nginx.pid
sleep 1
test -f /usr/local/nginx-1.6.3/logs/nginx.pid.oldbin
kill -QUIT cat /usr/local/nginx-1.6.3/logs/nginx.pid.oldbin

查看版本,发现已经是1.9.7版本,编译的参数也存在;

[root@localhost nginx-1.9.7]# /usr/local/nginx-1.6.3/sbin/nginx -V
nginx version: nginx/1.9.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: –prefix=/usr/local/nginx-1.6.3 –user=nginx –group=nginx –with-http_ssl_module –with-http_gzip_static_module –with-http_gunzip_module –with-http_stub_status_module –with-pcre

查看nginx进程 PID已经更改

[root@localhost nginx-1.9.7]# ps -lef | grep nginx
0 S root 3622 1 0 80 0 - 11259 rt_sig 17:25 ? 00:00:00 nginx: master process /usr/local/nginx-1.6.3/sbin/nginx -c /usr/local/nginx-1.6.3/conf/nginx.conf
5 S nginx 3624 3622 0 80 0 - 11363 ep_pol 17:25 ? 00:00:00 nginx: worker process

 

版权声明:
作者:WangGaoli
链接:https://wanggaoli.com/2892.html
来源:王高利的个人博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>