【问题标题】:What is the solution to this, Nginx stop when ever I restart it解决方案是什么,Nginx 在我重新启动时停止
【发布时间】:2019-11-07 16:28:30
【问题描述】:

当我重新启动 nginx 或重新启动 VPS nginx 和 nginx.service 停止。并给出这个错误。 sudo systemctl 启动 nginx nginx.service 的作业失败,因为控制进程以错误代码退出。详见“systemctl status nginx.service”和“journalctl -xe”。

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

[root@host ~]# systemctl status nginx.service * nginx.service - nginx - 高性能网络服务器 已加载:已加载(/usr/lib/systemd/system/nginx.service;已启用;供应商预设:已禁用) 活动:自 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) 主PID:692(nginx) CGroup:/system.slice/nginx.service |-692 nginx:主进程 /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 - 高性能网络服务器 已加载:已加载(/usr/lib/systemd/system/nginx.service;已启用;供应商预设:已禁用) 活动:自 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) 主 PID:692(code=exited,status=0/SUCCESS)

6 月 25 日 19:04:56 主机 systemd[1]:正在启动 nginx - 高性能 Web 服务器... Jun 25 19:04:56 host nginx[861]: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:33 Jun 25 19:04:56 host systemd[1]: nginx.service: control process exited, code=exited status=1 6 月 25 日 19:04:56 主机 systemd[1]:无法启动 nginx - 高性能 Web 服务器。 6 月 25 日 19:04:56 主机 systemd[1]:单元 nginx.service 进入失败状态。 Jun 25 19:04:56 host systemd[1]: nginx.service failed.

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

【问题讨论】:

    标签: nginx server nginx-reverse-proxy nginx-config


    【解决方案1】:

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

    Jun 25 19:04:56 host nginx[861]: nginx: [emerg] "server" 指令在 /etc/nginx/nginx.conf:33 中是不允许的

    表示/etc/nginx/nginx.conf的第33行,不应该有“server”语句。

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

    【讨论】:

    • 我删除了我将重新安装并提供给文件内容的所有安装。尽快。
    • 我重新安装了 nignx,然后通过获取帮助创建了一个 mainsite.conf 文件,并在 /etc/nginx/conf.d 中配置了 default.conf 文件,它工作正常。跨度>
    • 您指出的问题很有帮助,我需要创建一个单独的文件以使服务器能够正常工作。
    猜你喜欢
    • 1970-01-01
    • 2021-08-12
    • 2020-09-26
    • 1970-01-01
    • 2011-03-28
    • 2018-04-02
    • 1970-01-01
    • 2022-06-28
    • 2019-03-10
    相关资源
    最近更新 更多