如果改變了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 /yujialinwget http://nginx.org/download/nginx-1.0.6.tar.gz
tar zxvf nginx-1.0.6.tar.gz
cd nginx-1.0. 6
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
.這一步驟是要得到編譯參數
用上面這段編譯
mv /usr/local/www/nginx/sbin/nginx /usr/local/www/nginx/sbin/nginx-20110906
cp objs/nginx /usr/local/www/nginx/sbin/nginxobjs/nginx /usr/local/www/nginx/sbin/nginxobjs
##/usr/local/www/nginx/sbin/nginx -t
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.6nginx: built by gcc 4.1.2 20080704 (red hat 4.1.2-50)
nginx: configure arguments: --prefix=/usr/local/www/nginx --with-www/nginx --with pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
以上是nginx平滑重啟與升級怎麼實現的詳細內容。更多資訊請關注PHP中文網其他相關文章!