使用 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 主配置中可能存在错误设置,但不确定要查找什么。