今天配置服务器的时候,按照以往的来
server {
listen 80;
server_name xxx.com;
location / {
root /data/xxx;
index index.html;
}
}
然后url访问一直都是403forbidden。我那个去,什么原因,刚开始还以为是文件权限问题。然后执行命令:
chmod -R 755 /data/xxx
依然403。 然后就在想是不是nginx配置出错了,然后执行了一下
nginx -t
nginx: [warn] conflicting server name "xxx.com" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
这意思是说我的这个域名地址被忽略了,咋了 ,怎么配置的就被忽略了呢,难道是有定义过这个域名的了么,然后继续 排查:
grep -r xxx.com /etc/nginx/conf.d
/etc/nginx/conf.d/aaa.conf: server_name xxx.com;
/etc/nginx/conf.d/xxx.conf: server_name xxx.com;
我i去。还真的两条。aaa.conf排在xxx.conf前面,所以后面配置的就忽略了。 这样就在aaa.conf修改一下项目地址,执行
nginx -s reload
现在 就正常访问了。