1. 程式人生 > >Nginx(2) 啟動,停止,訊號控制

Nginx(2) 啟動,停止,訊號控制

一,啟動,停止,檢查配置檔案和重啟

啟動

 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

停止

kill -QUIT  pid    溫和停止

kill -TERM pid  快速停止

kill -INT pid    快速停止

強制停止

pkill -9 nginx

驗證配置檔案是否沒錯

/usr/local/nginx/sbin/nginx -t        或    /usr/local/nginx/sbin/nginx -t  -c /usr/local/nginx/conf/nginx.conf                      
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

重啟

 ./nginx -s reload 或者 kill -HUP pid

二,訊號控制

PUB重啟

QUIT溫和關閉

INT溫和關閉

TERM強制關閉

USR1切日誌

USR2平滑升級

WINCH關閉共總程序

檢視程序

[[email protected] nginx-1.10.1]# ps -ef|grep nginx
root      7110     1  0 11:12 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody    7111  7110  0 11:12 ?        00:00:00 nginx: worker process                                          
root      7116 28925  0 11:12 pts/0    00:00:00 grep nginx

可以看到 7110是主程序,7111是工作程序

[[email protected] nginx-1.10.1]# ps -ef|grep nginx
root      7110     1  0 11:12 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody    7111  7110  0 11:12 ?        00:00:00 nginx: worker process                                          
root      9437 28925  0 11:39 pts/0    00:00:00 grep nginx
[

[email protected] nginx-1.10.1]# kill -WINCH 7110
[[email protected] nginx-1.10.1]# ps -ef|grep nginx
root      7110     1  0 11:12 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
root      9439 28925  0 11:39 pts/0    00:00:00 grep nginx

平滑升級:

舊的請求依然處理,新的請求不再處理。

檢視版本

[[email protected] nginx-1.10.1]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.10.1