歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> nginx啟動、關閉、重啟,nginx啟動關閉重啟

nginx啟動、關閉、重啟,nginx啟動關閉重啟

日期:2017/3/6 9:40:03   编辑:學習Linux

nginx啟動、關閉、重啟,nginx啟動關閉重啟


nginx啟動、關閉、重啟,nginx啟動關閉重啟


1、啟動

[root@localhost local]# nginx/sbin/nginx   #啟動
[root@localhost local]# 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 successful
[root@localhost local]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      2756/nginx          

2、停止

[root@localhost sbin]# ps -ef | grep nginx   #查詢nginx主程序號,在進程列表裡找master進程,它的編號就是主進程號。
root      2811     1  0 17:52 ?        00:00:00 nginx: master process ./nginx
nobody    2838  2811  0 17:57 ?        00:00:00 nginx: worker process
root     27504  2707  0 19:07 pts/0    00:00:00 grep nginx
[root@localhost sbin]# kill -quit 2811  #從容停止nginx
[root@localhost sbin]# ps -ef | grep nginx 
root     27513  2707  0 19:08 pts/0    00:00:00 grep nginx

快速停止 kill -TERM 主進程號

強制停止 kill -9 nginx

3、重啟

如果更改了配置就要重啟Nginx,要先關閉Nginx再打開?可以向Nginx 發送信號,平滑重啟。
平滑重啟命令:
kill -HUP 主進程號或進程號文件路徑

或者使用

/usr/nginx/sbin/nginx -s reload

注意,修改了配置文件後最好先檢查一下修改過的配置文件是否正確,以免重啟後Nginx出現錯誤影響服務器穩定運行。判斷Nginx配置是否正確命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf

或者

/usr/nginx/sbin/nginx -t

http://xxxxxx/Linuxjc/1134426.html TechArticle

Copyright © Linux教程網 All Rights Reserved