文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Nginx启动出现Job for nginx.service failed because the control process exited with error code.

2023-09-02 09:33

关注

Nginx启动出现Restarting nginx (via systemctl): Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.问题

1、查看防火墙启动的端口号

[root@iZuf68mr29sh8zy1elsaixZ ~]# firewall-cmd --list-ports80/tcp 3306/tcp

2、重启防火墙

[root@iZuf68mr29sh8zy1elsaixZ ~]# firewall-cmd --reloadsuccess

3、重启nginx,出现如下错误

[root@iZuf68mr29sh8zy1elsaixZ ~]# service nginx restartRestarting nginx (via systemctl):  Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

这种错误一般都是目录不存在或者权限不足,所以直接执行下面两条命令即可,结果发现根本行不通。

[root@iZuf68mr29sh8zy1elsaixZ ~]# cd /var/tmp/[root@iZuf68mr29sh8zy1elsaixZ ~]# mkdir -p /var/tmp/Nginx/{client,proxy,fastcgi,uwsgi,scgi}

4、查看nginx服务

[root@iZuf68mr29sh8zy1elsaixZ ~]# systemctl status nginx.service● nginx.service - The nginx HTTP and reverse proxy server   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)   Active: failed (Result: exit-code) since Sun 2023-02-05 11:02:23 CST; 36s ago  Process: 1416 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)  Process: 1414 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ systemd[1]: Starting The nginx HTTP an...Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ nginx[1416]: nginx: the configuration ...Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ nginx[1416]: nginx: [emerg] bind() to ...Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ nginx[1416]: nginx: configuration file...Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ systemd[1]: nginx.service: control pro...Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ systemd[1]: Failed to start The nginx ...Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ systemd[1]: Unit nginx.service entered...Feb 05 11:02:23 iZuf68mr29sh8zy1elsaixZ systemd[1]: nginx.service failed.Hint: Some lines were ellipsized, use -l to show in full.

可以看到nginx出现错误:

Process: 1416 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)  Process: 1414 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, 

可以看出修改完配置信息后没有提交:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# nginx -t -c /etc/nginx/nginx.confnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: [emerg] bind() to 139.196.234.86:80 failed (99: Cannot assign requested a ddress)

结果发现80端口被占用:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# netstat -natp |grep 80tcp        0      0 172.16.85.16:43064      100.100.30.26:80        ESTABLISHED 1189/AliYunDun

将80端口杀死:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# kill 1189[root@iZuf68mr29sh8zy1elsaixZ tmp]# netstat -natp |grep 80tcp        0      0 172.16.85.16:43064      100.100.30.26:80        TIME_WAIT   -

5.测试nginx服务

执行测试:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

测试成功

重新加载配置文件:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# nginx -s reloadnginx: [error] invalid PID number "" in "/run/nginx.pid"

出现错误

重启:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# nginx -c /etc/nginx/nginx.confnginx: [emerg] bind() to 139.196.234.86:80 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:8000 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:80 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:8000 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:80 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:8000 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:80 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:8000 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:80 failed (98: Address already in use)nginx: [emerg] bind() to 139.196.234.86:8000 failed (98: Address already in use)nginx: [emerg] still could not bind()

发现报了如此对的错误信息

此时将nginx的所有进程都杀死:

killall nginx

重新启动nginx,就可以正常运行了

[root@iZuf68mr29sh8zy1elsaixZ tmp]# service nginx startStarting nginx (via systemctl):[  OK  ][root@iZuf68mr29sh8zy1elsaixZ tmp]# systemctl status nginx.service● nginx.service - The nginx HTTP and reverse proxy server   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)   Active: active (running) since Sun 2023-02-05 11:20:16 CST; 40s ago  Process: 1763 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)  Process: 1760 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)  Process: 1756 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 1764 (nginx)   CGroup: /system.slice/nginx.service           ├─1764 nginx: master process /usr/sbin/nginx           ├─1765 nginx: worker process           └─1766 nginx: worker processFeb 05 11:20:16 iZuf68mr29sh8zy1elsaixZ systemd[1]: Starting The nginx HTTP and reverse proxy server...Feb 05 11:20:16 iZuf68mr29sh8zy1elsaixZ nginx[1760]: nginx: the configuration file /etc/nginx/nginx.conf syntax is okFeb 05 11:20:16 iZuf68mr29sh8zy1elsaixZ nginx[1760]: nginx: configuration file /etc/nginx/nginx.conf test is s...sfulFeb 05 11:20:16 iZuf68mr29sh8zy1elsaixZ systemd[1]: Started The nginx HTTP and reverse proxy server.Hint: Some lines were ellipsized, use -l to show in full.

来源地址:https://blog.csdn.net/2201_75967071/article/details/128889409

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-服务器
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯