简体   繁体   English

NGINX server_name不起作用

[英]NGINX server_name not work

I ecountered the following issue about server_name in nginx and might need your help. 我在nginx中遇到了关于server_name的以下问题,可能需要你的帮助。 This is my default.cnf resided in /etc/nginx/conf.d/ 这是我的default.cnf位于/etc/nginx/conf.d/

server {
    listen       80;
    server_name  planner.dev;

    root   /var/www/planner.dev/src;
    index  index.php index.html index.htm;
    ...
}

And I have a helloworld html file in /var/www/planner.dev/src However, only localhost will run, planner.dev will not run. 我在/var/www/planner.dev/src有一个helloworld html文件但是,只有localhost会运行, planner.dev将无法运行。

$ curl planner.dev
curl: (6) Couldn't resolve host 'planner.dev'

The issue is fixed by editing the hosts file of Centos, not relating to NGINX. 通过编辑Centos的hosts文件修复了该问题,与NGINX无关。 Sorry everybody 对不起大家

The problem is most likely in the system hosting the server, than in the server itself. 问题很可能出在托管服务器的系统中,而不是服务器本身。

I was running an Nginx server on Debian and happened to have the same issue, which I solved by editing the /etc/hosts file likeso: 我在Debian上运行Nginx服务器,碰巧遇到了同样的问题,我通过编辑/etc/hosts文件解决了这个问题:

127.0.0.1       localhost
127.0.0.1       vacuum
127.0.0.1       <mywebsite>.localhost

More about the hosts file . 有关hosts文件的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM