我遇到了 ServerAliases 无法解析到相应服务器的问题。
我的主机文件是这样设置的(这是尝试设置 APE 的一部分,所以请原谅无关代码):
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 testy.local
127.0.0.1 testsite.local
127.0.0.1 ape-test.local
127.0.0.1 chickens.cluck.com
127.0.0.1 ape.ape-test.local
127.0.0.1 ape2.ape-test.local
和 httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName ape-test.local
ServerAlias ape.ape-test.local
ServerAlias test.ape-test.local
ServerAlias *.ape.ape-test.local
DocumentRoot "/Library/WebServer/Documents/"
</VirtualHost>
<VirtualHost *:80>
ServerName testy.local
ServerAlias testy
ServerAlias fish.local
DocumentRoot "/Users/myusername/Sites/testsite"
<Directory /Users/myusername/Sites/testsite/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
httpd.conf 中启用了虚拟主机,并且 testy.local 解析到正确的目录。但是使用 'testy/' 或 'fish.local' 将无法解决。
似乎也没有任何内容写入错误日志或控制台,并且运行sudo bash -x /usr/sbin/apachectl -k start
显示没有错误。运行httpd -S
也没有发现任何问题:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server ape-test.local (/private/etc/apache2/extra/httpd-vhosts.conf:44)
port 80 namevhost ape-test.local (/private/etc/apache2/extra/httpd-vhosts.conf:44)
port 80 namevhost testy.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
Syntax OK
所以看起来只是 ServerAlias 不起作用。
有人有什么想法吗?