nginx: [emerg] 重复的默认服务器

13
当我尝试重新启动nginx并在控制台中输入以下命令时:

nginx -t

我遇到了一个错误:
nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default.save:20
nginx: configuration file /etc/nginx/nginx.conf test failed

sites-enabled/default

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

        server_name localhost;
        passenger_enabled on;
        rails_env    production;
        root         /home/hh/public;

        access_log  /var/log/nginx/host.access.log;
        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

nginx.conf

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 768;
}

http {

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;


        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

一个小时之前一切正常,但在重新启动 nginx 之后,我出现了这个问题。


我认为这个链接 http://serverfault.com/questions/277653/nginx-name-based-virtual-hosts-on-ipv6 可以帮助你。 - kunashir
2个回答

20

如果你看一下/etc/nginx/sites-enabled/目录,你会看到有两个文件,default.savedefault,只需要移除其中一个文件即可。

 sudo rm -rf  /etc/nginx/sites-enabled/default.save 

我建议使用 ls -l /etc/nginx/sites-enabled/ 命令来查看是否存在更多的文件,例如 default.1 等。 - Daniel Muñoz
1
我有同样的问题,但在目录中没有default.save或任何其他类似的重复文件。 - sequence

1

您应该在默认配置文件中删除default_server


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接