Nginx启动出现Job for nginx.service failed because the control process exited with error code.
创始人
2024-11-13 22:11:24
0

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-ports 80/tcp 3306/tcp 

2、重启防火墙

[root@iZuf68mr29sh8zy1elsaixZ ~]# firewall-cmd --reload success 

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

[root@iZuf68mr29sh8zy1elsaixZ ~]# service nginx restart 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. 

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

[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.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] bind() to 139.196.234.86:80 failed (99: Cannot assign requested a ddress) 

结果发现80端口被占用:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# netstat -natp |grep 80 tcp        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 80 tcp        0      0 172.16.85.16:43064      100.100.30.26:80        TIME_WAIT   - 

5.测试nginx服务

执行测试:

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

测试成功

重新加载配置文件:

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

出现错误

重启:

[root@iZuf68mr29sh8zy1elsaixZ tmp]# nginx -c /etc/nginx/nginx.conf 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] 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 start Starting 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 process  Feb 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 ok Feb 05 11:20:16 iZuf68mr29sh8zy1elsaixZ nginx[1760]: nginx: configuration file /etc/nginx/nginx.conf test is s...sful Feb 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. 

相关内容

热门资讯

绝活儿辅助!广西老友玩老是输怎... 绝活儿辅助!广西老友玩老是输怎么办(辅助挂)都是真的有辅助app(讲解有挂)在进入广西老友玩老是输怎...
法门辅助!福建13水插件(辅助... 法门辅助!福建13水插件(辅助挂)一贯是有辅助技巧(有挂技术)1、许多玩家不知道福建13水插件辅助怎...
办法辅助!潮友会app下载官方... 办法辅助!潮友会app下载官方辅助器(辅助挂)真是真的是有辅助app(有挂教程)该软件可以轻松地帮助...
妙招辅助!邯郸胡乐挂辅助(辅助... 妙招辅助!邯郸胡乐挂辅助(辅助挂)好像存在有辅助插件(有挂方略)1、上手简单,内置详细流程视频教学,...
教程书辅助!乐酷辅助(辅助挂)... 教程书辅助!乐酷辅助(辅助挂)其实存在有辅助脚本(有挂细节)乐酷辅助能透视中分为三种模型:乐酷辅助模...
学习辅助!决战卡五星辅助(辅助... 学习辅助!决战卡五星辅助(辅助挂)本来真的是有辅助软件(有人有挂)学习辅助!决战卡五星辅助(辅助挂)...
绝活辅助!边锋嘉兴麻将辅助器(... 绝活辅助!边锋嘉兴麻将辅助器(辅助挂)真是真的有辅助神器(新版有挂)1、边锋嘉兴麻将辅助器公共底牌简...
举措辅助!枫叶辅助器(辅助挂)... 举措辅助!枫叶辅助器(辅助挂)本来存在有辅助技巧(竟然有挂)1、下载好枫叶辅助器正确养号方法之后点击...
讲义辅助!点我达辅助(辅助挂)... 讲义辅助!点我达辅助(辅助挂)一直存在有辅助技巧(有人有挂)1、点我达辅助辅助器安装包、点我达辅助辅...
模块辅助!威信茶馆有挂的吗(辅... 模块辅助!威信茶馆有挂的吗(辅助挂)一直真的是有辅助脚本(揭秘有挂)1、玩家可以在威信茶馆有挂的吗线...