apache如何设置多个域名共用80端口

手册/FAQ (511) 2015-11-26 11:47:44

解决: 确保有下面这行

NameVirtualHost *:80

使用Apache配置虚拟主机出现_default_ VirtualHost overlap on port 80, the first has precedence错误的解决方案:

in /etc/apache2/vhosts.d/vhosts.conf :

<virtualhost *:80>
      ServerAdmin webmaster @somedomain.com
      DocumentRoot /srv/www/somedomain
      ServerName www. somedomain.com
      ServerAlias somedomain.com
   </virtualhost>
   <virtualhost *:80>
      ServerAdmin webmaster @elsedomain.com
      DocumentRoot /srv/www/elsedomain
      ServerName www. elsedomain.com
      ServerAlias  elsedomain.com
   </virtualhost>
   <virtualhost *:80>
      ServerAdmin webmaster @otherdomain.com
      DocumentRoot /srv/www/otherdomain
      ServerName www. otherdomain.com
      ServerAlias otherdomain.com
   </virtualhost>

 /etc/hosts :

127.0.0.1     www. somedomain.com
   127.0.0.1     somedomain.com
   127.0.0.1     www. elsedomain.com
   127.0.0.1     elsedomain.com
   127.0.0.1     www. otherdomain.com
   127.0.0.1     otherdomain.com

重启

apache2ctl restart

 

THE END