Nginx_啟動時報錯:Job for nginx.service failed because the control process exited with error code. See "systemctl stat
一、報錯如下
Job for nginx.service failed because the control process exited with
error code. See "systemctl status nginx.service" and "journalctl -xe"
for details.
1
2
3
二、解決原因
1、先檢查nginx配置文件正否正確
輸入nginx -t 命令,如果反回 successful表示配置文件無錯誤,否則說明配置文件有錯誤。
[root@localhost /]# nginx -t -c /etc/nginx/nginx.conf
1
如果配置文件有錯誤,修改配置文件后,先執行 nginx -t 命令檢查配置文件無錯誤后,再執行nginx -s reload 重新加載配置文件命令。
[root@localhost /]# nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost nginx]# nginx -s reload -c /etc/nginx/nginx.conf
[root@localhost nginx]#
1
2
3
4
5
2、查看nginx服務狀態,根據服務狀態去判斷報錯原因
輸入systemctl status nginx.service 命令,查看服務狀態
[root@localhost /]# systemctl status nginx.service
1
由輸出的狀態日志(即下圖畫黃色框的部分)可知,80端口被占用導致啟動失敗
三、解決方式
1、查看80端口被哪些程序所占用,輸入如下命令
[root@localhost /]# netstat -nap | grep 80
1
2、殺掉被占用的端口進程號,再次查看80端口是否有被占用,輸入如下命令
[root@localhost /]# kill -9 pid
1
3、重啟nginx服務,報錯消失,再查看nginx服務狀態顯示successful。
[root@localhost /]# systemctl start nginx
[root@localhost /]# systemctl status nginx.service
1
2
————————————————
版權聲明:本文為CSDN博主「小志的博客」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/li1325169021/article/details/118462921

浙公網安備 33010602011771號