在我的错误日志中我得到
[emerg] 10619#0: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/mysite.com:4
在 4 号线上我有:
server_name mysite.com www.mysite.com;
有什么建议吗?
最佳答案
您可能在 /etc/nginx/sites-enabled
中还有其他文件(例如 默认
配置)需要删除。
此问题是由于重复提供给文件中的一个或多个 listen
指令的 default_server
参数导致的。您可能会发现这个冲突的指令类似于:
listen 80 default_server;
作为nginx core module documentation for listen
状态:
The
default_server
parameter, if present, will cause the server to become the default server for the specifiedaddress:port
pair. If none of the directives have thedefault_server
parameter then the first server with theaddress:port
pair will be the default server for this pair.
这意味着您的配置中必须定义另一个文件或 server
block ,并为端口 80 设置 default_server
。 nginx 在您的 mysite 之前首先遇到该情况.com
文件,因此请尝试删除或调整其他配置。
如果您很难找到这些指令和参数的设置位置,请尝试如下搜索:
grep -R default_server /etc/nginx
关于nginx-重复的默认服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30973774/