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了