nginx平滑重启与升级怎么实现
如果改变了nginx的配置文件(nginx.conf),想重启nginx,同样可以通过发送系统信号给nginx主进程的方式来进行.不过,重启之前,要确认nginx配置文件(nginx.conf)的语法是正确的,否则nginx将不会加载新的配置文件。通过以下命令可以判断nginx配置文件是否正确:
/usr/local/webserver/nginx/sbin/nginx -t -c
/usr/local/webserver/nginx/conf/nginx.conf
如果配置文件不正确,屏幕将会提示配置文件的第几行出错:
[emerg]:unknowndirective"abc"inlusrllocauwebserverlnginxjconflnginx.conf:55
configurationfile/usr/local/webserver/nginx/conf/nginx·conf test failed
如果配置文件正确,屏幕将提示以下两行信息:
the configuration file/usr/loca/webserver/nginx/conf/nginx.conf syntax is ok
configuration file/usr/local/webserver/nginx/conf/nginx.conf test is successful
这时候,就可以平滑重启nginx了。
复制代码 代码如下:
/usr/local/www/nginx/sbin/nginx -xs reloadx
或:
复制代码 代码如下:
killx -hup `cat /usr/local/www/nginx/logs/nginx.pidx`
下面是一些补充:
平滑重启 kill -hup `cat /usr/local/www/nginx/logs/nginx.pid`
平滑升级nginx
cd /yujialin
wget http://nginx.org/download/nginx-1.0.6.tar.gz
tar zxvf nginx-1.0.6.tar.gz
cd nginx-1.0.6
/usr/local/www/nginx/sbin/nginx -v
nginx: nginx version: nginx/1.0.4
nginx: built by gcc 4.1.2 20080704 (red hat 4.1.2-50)
nginx: configure arguments: --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
这步是要得到编译参数
./configure --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
用上面这段编译
然后make,千万别make install
make完了 在objs目录下就多了个nginx,这个就是新版本的程序了
mv /usr/local/www/nginx/sbin/nginx /usr/local/www/nginx/sbin/nginx-20110906
cp objs/nginx /usr/local/www/nginx/sbin/nginx
/usr/local/www/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 successfu
make upgrade 执行升级
执行完后 /usr/local/nginx/sbin/nginx -v
nginx: nginx version: nginx/1.0.6
nginx: built by gcc 4.1.2 20080704 (red hat 4.1.2-50)
nginx: configure arguments: --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
以上就是nginx平滑重启与升级怎么实现的详细内容,更多请关注其它相关文章!