配置apache的虚拟机,设置不同的域名访问路径
<VirtualHost 127.0.0.1:80> DocumentRoot D:\wamp\www\comic\trunk\comic ServerName comic127.178.com ...... </VirtualHost> <VirtualHost 127.0.0.1:80> DocumentRoot "D:\wamp\www\comic\trunk\comic\mh" ServerName manhua127.178.com ...... </VirtualHost>
运行后进行访问,发现全部都指向第一个设置的 D:\wamp\www\comic\trunk\comic 路径下
查看 apache_error.log 文件,发现下面的错误警告:
[Fri Aug 03 14:05:56 2012] [warn] VirtualHost 127.0.0.1:80 overlaps with VirtualHost 127.0.0.1:80, the first has precedence, perhaps you need a NameVirtualHost directive
解决方法:
添加 NameVirtualHost ,代码如下
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1:80> DocumentRoot D:\wamp\www\comic\trunk\comic ServerName comic127.178.com ...... </VirtualHost> <VirtualHost 127.0.0.1:80> DocumentRoot "D:\wamp\www\comic\trunk\comic\mh" ServerName manhua127.178.com ...... </VirtualHost>
保存重启apache,再访问,成功.