nginx啟動、重啟、關閉 nginx啟動、重啟、關閉
nginx啟動、重啟、關閉
一.啟動
cd usr/local/nginx/sbin ./nginx
二.重啟
更改配置重啟nginx
kill -HUP 主程序號或程序號檔案路徑
或者使用
cd /usr/local/nginx/sbin ./nginx -s reload
判斷配置檔案是否正確
nginx -t -c /usr/local/nginx/conf/nginx.conf
或者
cd /usr/local/nginx/sbin ./nginx -t
三.關閉
查詢nginx主程序號
ps -ef | grep nginx
從容停止 kill -QUIT 主程序號
快速停止 kill -TERM 主程序號
強制停止 kill -9 nginx
若nginx.conf配置了pid檔案路徑,如果沒有,則在logs目錄下
kill -訊號型別 '/usr/local/nginx/logs/nginx.pid'
四.升級
1.先用新程式替換舊程式檔案
2.kill -USR2 舊版程式的主程序號或者程序檔名
此時舊的nginx主程序會把自己的程序檔案改名為.oldbin,然後執行新版nginx,此時新舊版本同時執行
3.kill -WINCH 舊版本主程序號
4.不過載配置啟動新/舊工作程序
kill -HUP 舊/新版本主程序號
從容關閉舊/新程序,kill -QUIT 舊/新程序號
快速關閉舊/新程序,kill -TERM 舊/新程序號
五.實際應用中經常使用
實際應用中經常是關閉,再啟動,nginx的啟動命令是:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-c制定配置檔案的路徑,不加-nginx會自動載入預設路徑的配置檔案。
以上是通用的啟動命令,研究了一下nginx幫助後發現,有-s引數可對nginx服務進行管理:
# /usr/local/nginx/sbin/nginx -h nginx version: nginx/0.7.63 Usage: nginx [-?hvVt] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -s signal : send signal to a master process: 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
# /usr/local/nginx/sbin/nginx -s reload
一.啟動
cd usr/local/nginx/sbin ./nginx
二.重啟
更改配置重啟nginx
kill -HUP 主程序號或程序號檔案路徑
或者使用
cd /usr/local/nginx/sbin ./nginx -s reload
判斷配置檔案是否正確
nginx -t -c /usr/local/nginx/conf/nginx.conf
或者
cd /usr/local/nginx/sbin ./nginx -t
三.關閉
查詢nginx主程序號
ps -ef | grep nginx
從容停止 kill -QUIT 主程序號
快速停止 kill -TERM 主程序號
強制停止 kill -9 nginx
若nginx.conf配置了pid檔案路徑,如果沒有,則在logs目錄下
kill -訊號型別 '/usr/local/nginx/logs/nginx.pid'
四.升級
1.先用新程式替換舊程式檔案
2.kill -USR2 舊版程式的主程序號或者程序檔名
此時舊的nginx主程序會把自己的程序檔案改名為.oldbin,然後執行新版nginx,此時新舊版本同時執行
3.kill -WINCH 舊版本主程序號
4.不過載配置啟動新/舊工作程序
kill -HUP 舊/新版本主程序號
從容關閉舊/新程序,kill -QUIT 舊/新程序號
快速關閉舊/新程序,kill -TERM 舊/新程序號
五.實際應用中經常使用
實際應用中經常是關閉,再啟動,nginx的啟動命令是:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-c制定配置檔案的路徑,不加-nginx會自動載入預設路徑的配置檔案。
以上是通用的啟動命令,研究了一下nginx幫助後發現,有-s引數可對nginx服務進行管理:
# /usr/local/nginx/sbin/nginx -h nginx version: nginx/0.7.63 Usage: nginx [-?hvVt] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -s signal : send signal to a master process: 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
# /usr/local/nginx/sbin/nginx -s reload