关于apache虚拟机的NameVirtualHost错误

配置apache的虚拟机,设置不同的域名访问路径

复制代码

<</span>VirtualHost 127.0.0.1:80>
DocumentRoot     D:\wamp\www\comic\trunk\comic
ServerName     comic127.178.com
......
</</span>VirtualHost>


<</span>VirtualHost 127.0.0.1:80>
DocumentRoot    "D:\wamp\www\comic\trunk\comic\mh"
ServerName     manhua127.178.com
......
</</span>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
<</span>VirtualHost 127.0.0.1:80>
DocumentRoot     D:\wamp\www\comic\trunk\comic
ServerName     comic127.178.com
......
</</span>VirtualHost>


<</span>VirtualHost 127.0.0.1:80>
DocumentRoot    "D:\wamp\www\comic\trunk\comic\mh"
ServerName     manhua127.178.com
......
</</span>VirtualHost>
复制代码
保存重启apache,再访问,成功.

你可能感兴趣的:(apache)