服务 nginx 重启失败

service nginx restart fails

我通过 运行 nginx -t 检查了配置语法,然后得到结果:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

但是当我 运行 service nginx restart 失败时。

我在 sites-enabled 文件夹中有一个名为 a.com 的配置文件,内容如下:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name a.com;

    # root /usr/share/nginx/html;
    # index index.html index.htm;
    root /home/a/public;

    client_max_body_size 10G;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}

我在 Ubuntu 14.10,想部署一个 rails 服务器。

我手动kill掉nginx的进程,然后重新启动nginx,问题解决了。

我遇到了这个问题,使用 sudo 解决了它:

sudo service nginx restart

启用日志检查错误可能会有所帮助:

https://www.nginx.com/resources/admin-guide/logging-and-monitoring/