啟動nginx服務時如果遇到這個錯誤 Job for nginx.service failed because the control process exited with error code. See “systemctl stat 可能原因如下:
1.nginx配置文件有錯誤
運行下面命令查看修改
nginx -t
2.已經啟動nginx或者配置文件中的端口號被占用
檢查端口是否被占用
netstat -tnlp
如果端口已經被占用,自己權衡一下是換個端口還是把占用端口的進程殺掉
如果已經啟動使用下面命令干掉即可
pkill -9 nginx
3.關閉
service nginx stop systemctl stop nginx
4.啟動
service nginx start systemctl start nginx
5.重啟
service nginx reload systemctl restart nginx
6.隨系統啟動自動運行
systemctl enable nginx
7.禁止隨系統啟動自動運行
systemctl disable nginx
擴展:
首先利用配置文件啟動nginx命令: nginx -c /usr/local/nginx/conf/nginx.conf 重啟服務: service nginx restart 快速停止或關閉Nginx:nginx -s stop 正常停止或關閉Nginx:nginx -s quit 配置文件修改重裝載命令:nginx -s reload