关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

解决Nginx状态出现"Job for nginx.service failed"问题排查

发布时间:2022/8/31 14:33:52
香港云服务器

前天八艾云在正常给一台服务器重新安装LNMP环境的时候,且在最后可以看到成功界面。于是就正常的重新部署站点环境添加站点转移数据,且解析也确定没有问题,可是网站还是打不开,我开始以为是域名我本地没有解析成功,让其他同事帮忙打开依旧是无法打开的。可以判断出来当前服务器配置环境出现故障。

于是检查Nginx状态重启发现有故障:

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

然后再检查Nginx的状态:

>>> systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2019-08-13 07:17:32 CST; 32s ago
Docs: http://nginx.org/en/docs/ From itbulu.com
Process: 21862 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

Feb 06 09:10:22 10-46-88-14 systemd[1]: Starting nginx - high performance web server...
Feb 06 09:10:22 10-46-88-14 nginx[21862]: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:35
Feb 06 09:10:22 10-46-88-14 systemd[1]: nginx.service: control process exited, code=exited status=1
Feb 06 09:10:22 10-46-88-14 systemd[1]: Failed to start nginx - high performance web server.
Feb 06 09:10:22 10-46-88-14 systemd[1]: Unit nginx.service entered failed state.
Feb 06 09:10:22 10-46-88-14 systemd[1]: nginx.service failed.


可以判断出来端口应该是被占用还是配置conf文件有错误,理应不应该的,因为是直接自动化安装的,手工安装可能会文件配置错误,自动不可能问题。且检查80端口也没有被占用,在解决问题的时候又发现MYSQL又无法连接。

最后感觉实在太麻烦,直接重新格式化系统,重新安装一遍,居然没有问题。可能在部署WEB系统的时候中间有出现意外导致的,与其这样找问题,反正服务器里没有数据,那还是直接重新格式化来一遍简单。