Apache2 忽略了子域名的虚拟主机,而是使用默认虚拟主机

Apache2 忽略了子域名的虚拟主机,而是使用默认虚拟主机

我在 Debian 9.1 上运行 Apache2 (2.4.10)。我在“/etc/apache2/sites-available/”中配置了几个子域,并使用 a2ensite *** 激活了它们。

除一个子域名外,所有子域名均按预期运行。此子域名将被忽略并使用默认虚拟主机。

假设我的域名是 myDomain.com。我有多个配置文件: - aaa.myDomain.com - bbb.myDomain.com - ccc.myDomain.com - myDomain.com - xxx.myDomain.com - zzz.myDomain.com

zzz.myDomain.com 不起作用。我复制了一个现有的、有效的配置文件,切换了其中的名称,但仍然不起作用。所有子域配置都相同,只是给定的名称发生了变化。

<VirtualHost  *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html/zzz.myDomain.com
  ServerName zzz.myDomain.com
  ServerAlias *.zzz.myDomain.com
  ErrorLog logs/zzz.myDomain.com-error_log
  CustomLog logs/zzz.myDomain.com-access_log common
</VirtualHost>

默认虚拟主机配置如下

<VirtualHost  *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html
  ServerName myDomain.com
  ErrorLog logs/myDomain.com-error_log
  CustomLog logs/myDomain.com-access_log common
</VirtualHost>

Apache2ctl -S 给出以下输出

*:80                   is a NameVirtualHost
default server myDomain.com (/etc/apache2/sites-enabled/myDomain.com.conf:2)
port 80 namevhost myDomain.com (/etc/apache2/sites-enabled/myDomain.com.conf:2)
port 80 namevhost aaa.myDomain.com (/etc/apache2/sites-enabled/aaa.myDomain.com.conf:2)
       wild alias *.aaa.myDomain.com
port 80 namevhost demo.myDomain.com (/etc/apache2/sites-enabled/demo.myDomain.com.conf:2)
       wild alias *.demo.myDomain.com
port 80 namevhost bbb.myDomain.com (/etc/apache2/sites-enabled/bbb.myDomain.com.conf:2)
       wild alias *.bbb.myDomain.com
port 80 namevhost ccc.myDomain.com (/etc/apache2/sites-enabled/ccc.myDomain.com.conf:2)
       wild alias *.ccc.myDomain.com
port 80 namevhost ddd.myDomain.com (/etc/apache2/sites-enabled/ddd.myDomain.com.conf:2)
       wild alias *.ddd.myDomain.com
port 80 namevhost eee.myDomain.com (/etc/apache2/sites-enabled/eee.myDomain.com.conf:2)
       wild alias *.eee.myDomain.com
port 80 namevhost fff.myDomain.com (/etc/apache2/sites-enabled/fff.myDomain.com.conf:2)
       wild alias *.fff.myDomain.com
port 80 namevhost ggg.myDomain.com (/etc/apache2/sites-enabled/ggg.myDomain.com.conf:2)
       wild alias *.ggg.myDomain.com
port 80 namevhost myDomain.com (/etc/apache2/sites-enabled/myDomain.com.conf:2)
       alias myDomain.com
port 80 namevhost xxx.myDomain.com (/etc/apache2/sites-enabled/xxx.myDomain.com.conf:2)
       wild alias *.xxx.myDomain.com
port 80 namevhost zzz.myDomain.com (/etc/apache2/sites-enabled/zzz.myDomain.com.conf:2)
       wild alias *.zzz.myDomain.com

相关内容