加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

nginx – 一台服务器上的多个域指向错误的站点

发布时间:2020-12-13 21:20:45 所属栏目:Nginx 来源:网络整理
导读:使用Nginx,我为一个服务器创建了一个多域设置,该服务器由四个单独的站点组成.当我启动Nginx时,我收到一条错误消息,并且网站似乎混淆了,因为输入一个网址会导致其他网站之一. 显示错误消息 Restarting nginx: nginx: [warn] conflicting server name "localho

使用Nginx,我为一个服务器创建了一个多域设置,该服务器由四个单独的站点组成.当我启动Nginx时,我收到一条错误消息,并且网站似乎混淆了,因为输入一个网址会导致其他网站之一.

显示错误消息 –

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.

我已经在/ 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从您在include指令中的路径加载其外部服务器文件.

如果你有一个包含/etc/nginx/conf.d/*.conf的文件;并且它的符号链接包括/ etc / nginx / sites-enabled它将加载文件两次,这将导致该错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读