当前位置:Gxlcms > PHP教程 > nginx之平滑升级详解

nginx之平滑升级详解

时间:2021-07-01 10:21:17 帮助过:3人阅读

最近感觉公司的nginx版本太低了并且我们又要添加新的nginx模块所以只能想到的就是平滑升级这一个办法了。Nginx更新真的很快,最近nginx的0.8.55和nginx的0.7.69旧的稳定版本已经发布。我一项比较喜欢使用新版本的软件,于是把原来的nginx-1.0.2平滑升级至nginx-1.0.5稳定版。并记录这一过程,希望对有需要的朋友有点帮助。

1. 开始之前先查看一下当前使用的版本。

# /usr/local/nginx/sbin/nginx -V nginx: nginx version: nginx/1.0.5 nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50) nginx: TLS SNI support disabled nginx: configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-cc-opt=-O3 --with-cpu-opt=opteron --with-http_gzip_static_module注意红色区域,这是以前编译的参数。马上编辑新版本需要用到。

2.下载新版本:http://nginx.org/en/download.html

然后:解压 > 便以前的准备 > 编译

# tar zxvf nginx-1.0.5.tar.gz # cd nginx-1.0.5 # ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-cc-opt='-O3' --with-cpu-opt=opteron --with-http_gzip_static_module # make3. 执行完后,这里不用在 make install 了,接下来重名/sbin/nginx为nginx.old

# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old4. 复制编译后objs目录下的nginx文件到nginx的安装目录sbin/下

# cp objs/nginx /usr/local/nginx/sbin/5. 测试一下新复制过来文件生效情况:

# /usr/local/nginx/sbin/nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful6. 让nginx把nginx.pid文件修改成nginx.pid.oldbin,随即启动nginx,实现不间断服务运行

# kill -USR2 `cat /usr/local/nginx/nginx.pid`(发送平滑升级信号将旧的nginx.pid文件添加后缀nginx.pid.oldbin)#kill -WINCH(平缓停止worker process) `cat /usr/local/nginx/nginx.pid.oldbin # kill -QUIT `cat /usr/local/nginx/nginx.pid.oldbin`7. 升级完成了,最后在看一下升级后的版本

# /usr/local/nginx/sbin/nginx -v nginx: nginx version: nginx/1.0.5

以上就介绍了nginx之平滑升级详解,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行