Nginx的启动、停止和重启
生活随笔
收集整理的這篇文章主要介紹了
Nginx的启动、停止和重启
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
啟動
啟動代碼格式:nginx安裝目錄地址 -c nginx配置文件地址
例如:
[root@sijizhen sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf停止
nginx有三種停止方式:
從容停止
1.查看進程??ps -ef|grep nginx
[root@sijizhen sbin]# ps -ef|grep nginx root 9862 1 0 01:04 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf nobody 9863 9862 0 01:04 ? 00:00:00 nginx: worker process root 9886 1612 0 01:15 pts/0 00:00:00 grep nginx2.殺死進程??
[root@sijizhen sbin]# kill -QUIT 9862快速停止
1、查看進程號
[root@sijizhen sbin]# ps -ef|grep nginx root 9892 1 0 01:17 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf nobody 9893 9892 0 01:17 ? 00:00:00 nginx: worker process root 9895 1612 0 01:18 pts/0 00:00:00 grep nginx2.殺死進程
[root@sijizhen sbin]# kill -TERM 9892強制停止
[root@sijizhen sbin]# pkill -9 nginx重啟
1、驗證nginx配置文件是否正確
方法一:進入nginx安裝目錄sbin下,輸入命令./nginx -t
[root@sijizhen 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說明配置文件正確!
方法二:在啟動命令-c前加-t
[root@sijizhen sbin]# /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?2、重啟Nginx服務
?方法一:進入nginx可執行目錄sbin下,輸入命令./nginx -s reload?即可
[root@sijizhen sbin]# ./nginx -s reload方法二:查找當前nginx進程號,然后輸入命令:kill -HUP 進程號 實現重啟nginx服務
[root@sijizhen sbin]# ps -ef|grep nginx root 9928 1 0 01:24 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf nobody 9935 9928 0 01:25 ? 00:00:00 nginx: worker process root 9938 1612 0 01:26 pts/0 00:00:00 grep nginx [root@sijizhen sbin]# kill -HUP 9928參考:https://www.cnblogs.com/codingcloud/p/5095066.html
轉載于:https://www.cnblogs.com/sijizhen/p/10579696.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Nginx的启动、停止和重启的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php基础-2
- 下一篇: 安装Nginx时报错 the HTTP