【发布时间】:2014-02-21 00:49:51
【问题描述】:
使用 Nginx,我为一台服务器创建了一个多域设置,该服务器由四个单独的站点组成。当我启动 Nginx 时,我收到一条错误消息,并且站点似乎混淆了,因为输入一个 url 会导致另一个站点之一。
显示的错误信息 -
Restarting nginx: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx.
我已经在 /sites-available 下的各自文件中以类似的方式设置了所有四个域 -
server {
listen 80;
root /var/www/example.com/public_html;
index index.php index.html index.htm;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ /index.html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我已经检查过,/sites-enabled 中没有默认文件。猜测 Nginx 主配置中可能存在错误设置,但不确定要查找的内容。
【问题讨论】:
-
也许您在主配置文件 (
nginx.conf) 中定义了server? -
不,只有 http 和事件选项。有什么特别值得我寻找的吗?
-
我问是因为默认的
nginx.conf有一堆示例server块,也许你忘了删除它们。您的主配置文件中有什么?你能把它发布到 pastebin 或类似的东西吗?
标签: nginx multiple-domains server-configuration