nginx上配置vhosts

今天在配置nginx的时候出了一件很囧的事情,以前配置是这样的

/usr/local/nginx/conf/

  -nginx.conf

  -my.conf

然后在nginx.conf里加上 include my.conf

今天我发现conf下面还有个vhosts的文件夹,于是我就这样做

/usr/local/nginx/conf/

  -nginx.conf

  vhosts/

    -my.conf

然后在nginx.conf里写了include vhosts/my.conf

再加来运行

/usr/local/nginx/sbin/nginx -t

结果提示我虚拟域名配置重复了!

果断查询一下

find /usr/local/nginx/conf -name "*.conf" | xargs grep -n "my.domain"

结果没发现重复,我google了很长时间,最后灵光一闪!

cat /usr/local/nginx/conf/nginx.conf | grep vhosts

结果是

include vhosts/*.conf

太囧了!