Apache加VirtualHost后通过IP无法正确访问

Standard

问题:
之前在apache上配了svn和trac是通过IP进行访问.
现在要加了个VirtualHost,加完后发现原IP访问的DocumentRoot无法访问.

解决方法:
在vhost的配置中加上

<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot /home/apache/htdocs
</VirtualHost>

关于Apache2 VirtualHost二级域名只生效一个的问题

Standard

Apache2 config文件新增二级域名如下:
<VirtualHost *:80>
ServerName maillist.yemaosheng.com
ServerAlias maillist.yemaosheng.com
DocumentRoot /var/www/html/maillist.yemaosheng.com
</VirtualHost>
<VirtualHost *:80>
ServerName cms.yemaosheng.com
ServerAlias cms.yemaosheng.com
DocumentRoot /var/www/html/cms.yemaosheng.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.yemaosheng.com
DocumentRoot /var/www/html/www.yemaosheng.com
</VirtualHost>

本地电脑上hosts.ini文件已经添加
192.168.42.12 maillist.yemaosheng.com
192.168.42.12 cms.yemaosheng.com
192.168.42.12 www.yemaosheng.com

只能访问到maillist.yemaosheng.com
cms.yemaosheng.com还是指到maillist.yemaosheng.com上面了
而www.yemaosheng.com则显示You don”t have permission to access / on this server.
感觉后面加的二级域名只能匹配到maillist.yemaosheng.com

问题解决
vhost的config文件头上加一行 NamevirtualHost *:80 就OK了