[英]Apache ServerName * wildcard not working with vhost_dbd_module
I'm trying to migrate my virtualhosts to a mysql database using vhost_dbd_module. 我正在尝试使用vhost_dbd_module将虚拟主机迁移到mysql数据库。
In the various examples I find online, they instruct me to use "ServerName *" as a wildcard in the VirtualHost. 在网上找到的各种示例中,它们指示我在VirtualHost中使用“ ServerName *”作为通配符。
When I configure my VirtualHost this way, the server just defaults back to the default DocumentRoot. 当我以这种方式配置我的VirtualHost时,服务器只是默认回到默认的DocumentRoot。 It does not query the mysql database.
它不查询mysql数据库。
<VirtualHost *:80>
# catch all other requests that don't get caught above
ServerName *
# fallbackDocumentRoot in case mysql server is down
DocumentRoot /var/html/404
DBDriver mysql
DBDParams "host=<hostname> user=<user> dbname=<dbname>"
DBDocRoot "SELECT documentRoot FROM virtualhosts WHERE serverName = %s" HOSTNAME
</VirtualHost>
However, when I change it to this (specify the ServerName to domain.tld), it works properly (queries the database for domain.tld and returns the proper documentroot for domain.tld) 但是,当我将其更改为此(将ServerName指定为domain.tld)时,它可以正常工作(为domain.tld查询数据库,并为domain.tld返回正确的documentroot)
<VirtualHost *:80>
# catch all other requests that don't get caught above
ServerName domain.tld
# fallbackDocumentRoot in case mysql server is down
DocumentRoot /var/html/404
DBDriver mysql
DBDParams "host=<hostname> user=<user> dbname=<dbname>"
DBDocRoot "SELECT documentRoot FROM virtualhosts WHERE serverName = %s" HOSTNAME
</VirtualHost>
Any ideas what is misconfigured? 有什么想法配置错误吗?
After messing around some more, it appears that ServerName * only works when it is the FIRST VirtualHost in the system. 经过一番混乱之后,ServerName *仅在它是系统中的第一个VirtualHost时才起作用。
I moved it first in order, with a few other virtualhosts beneath it (with more specific ServerName example.tld) and both the DB hosts and the statically configured hosts worked. 我首先按顺序移动它,在它下面还有其他几个虚拟主机(更具体的ServerName example.tld),并且数据库主机和静态配置的主机都可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.