技术分享 服务器部署nginx报错 nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored

swabie · 2019-08-26 11:11:20 · 热度: 31

nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored

修改nginx配置参数后,使用nginx -t检查配置.

提示successfull后就可以使用 nginx -s reload来重新加载配置

我配置的过程中遇到这样的问题,就是绑定了主机名后,重新加载配置时会出现警告

nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.codercto.com" on 0.0.0.0:80, ignored

www.codercto.com 这个域名出现了两次甚至多次,把同一个域名解析到了不同的目录。一般将配置文件单独分离出来容易出现这个错误。

重复绑定了server name,但这个警告不会影响到服务器运行。而且,这个重复绑定的意思是现在运行的nginx服务和将要加载的新配置中的重复,所以,这个警告其实是不必的。

查询哪些文件里面包含了 www.codercto.com 字段 。使用grep命令,该命令实例如下:

sudo grep -r www.codercto.com /etc/nginx/conf.d/

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册