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

posted @ 2023-05-22 18:35  翻滚的小强  阅读(1405)  评论(0编辑  收藏  举报