天天看點

nginx指令行參數和信号

nginx指令行參數

[user@host dir]$ /usr/local/nginx/sbin/nginx -h

nginx version: nginx/1.8.0

Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:

-?,-h : this help  檢視幫助資訊

-v : show version and exit 顯示 nginx 的版本

-V : show version and configure options then exit 顯示 nginx 的版本,編譯器版本和配置參數

-t : test configuration and exit 不運作,而僅僅測試配置檔案。nginx 将檢查配置檔案的文法的正确性,并嘗試打開配置檔案中所引用到的檔案。

-q : suppress non-error messages during configuration testing

-s signal : send signal to a master process: stop, quit, reopen, reload  傳遞一個信号,stop快速關閉,quit從容關閉,reopen重新打開日志檔案、用于切換日志檔案,reload重載配置檔案

-p prefix : set prefix path (default: /usr/local/nginx/)

-c filename : set configuration file (default: conf/nginx.conf)  設定配置檔案

-g directives : set global directives out of configuration file

通過系統的信号控制 Nginx

可以使用信号系統來控制主程序。預設,nginx 将其主程序的 pid 寫入到 /usr/local/nginx/logs/nginx.pid 檔案中。通過傳遞參數給 ./configure 或使用 pid 指令,來改變該檔案的位置。

主程序可以處理以下的信号:

TERM, INT 快速關閉
QUIT 從容關閉
HUP

重載配置

用新的配置開始新的工作程序

從容關閉舊的工作程序

USR1 重新打開日志檔案
USR2 平滑更新可執行程式。
WINCH 從容關閉工作程序

盡管你不必自己操作工作程序,但是,它們也支援一些信号:

示例:重新加載配置檔案

[user@host dir] kill -HUP `cat /usr/local/nginx/logs/nginx.pid`

上一篇: nginx優化