首页 > 解决方案 > 解决方案是什么,Nginx 在我重新启动时停止

问题描述

每当我重新启动 nginx 或重新启动 VPS nginx 和 nginx.service 停止。并给出这个错误。sudo systemctl start nginx Job for nginx.service 失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status nginx.service”和“journalctl -xe”。

我正在使用 Centos 7.6 并安装了来自 nginx.org 的主线 nginx 最新版本。

[root@host ~]# systemctl status nginx.service * nginx.service - nginx - 高性能 web 服务器 Loaded: 已加载 (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (运行)自 2019 年 6 月 25 日星期二 18:41:49 UTC 起;22分钟前 文档:http ://nginx.org/en/docs/ 进程:670 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS) 进程:691 ExecStart=/usr/sbin /nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Main PID: 692 (nginx) CGroup: /system.slice/nginx.service |-692 nginx: master process /usr/ sbin/nginx -c /etc/nginx/nginx.conf `-693 nginx:工作进程

6 月 25 日 18:41:49 主机 systemd[1]:启动 nginx - 高性能 Web 服务器... 6 月 25 日 18:41:49 主机 systemd[1]:PID 文件 /var/run/nginx.pid 不可读(还?) 开始后。6 月 25 日 18:41:49 主机 systemd[1]:启动 nginx - 高性能 Web 服务器。[root@host ~]# systemctl restart nginx nginx.service 的作业失败,因为控制进程退出并出现错误代码。有关详细信息,请参阅“systemctl status nginx.service”和“journalctl -xe”。[root@host ~]# systemctl status nginx.service * nginx.service - nginx - 高性能 web 服务器 Loaded: 已加载 (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: failed (结果:退出代码)自 2019 年 6 月 25 日星期二 19:04:56 UTC 起;21 秒前文档: http: //nginx.org/en/docs/ 进程:858 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS) 进程:861 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited , status=1/FAILURE) Main PID: 692 (code=exited, status=0/SUCCESS)

6 月 25 日 19:04:56 主机 systemd[1]:启动 nginx - 高性能 Web 服务器... 6 月 25 日 19:04:56 主机 nginx[861]:nginx:[emerg] “server”指令在此处不允许/etc/nginx/nginx.conf:33 Jun 25 19:04:56 host systemd[1]: nginx.service: control process exited, code=exited status=1 Jun 25 19:04:56 host systemd[1]:无法启动 nginx - 高性能 Web 服务器。6 月 25 日 19:04:56 主机 systemd[1]:单元 nginx.service 进入失败状态。6 月 25 日 19:04:56 主机 systemd[1]:nginx.service 失败。

也许它监听端口:80(httpd)。如果是如何删除它并在每次启动时将 nginx 设置为默认值。除此之外,我不知道是什么导致了这个问题。我正在尝试使用 Nginx 作为反向代理。任何有效的解决方案都是有价值的。这是我第三次安装 Nginx。

标签: nginxservernginx-reverse-proxynginx-config

解决方案


您的消息中存在配置错误:

Jun 25 19:04:56 host nginx[861]: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:33

这意味着在 /etc/nginx/nginx.conf 的第 33 行,不应该有“server”语句。

分享你的 /etc/nginx/nginx.conf 怎么样?


推荐阅读