我遇到了 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 不起作用。
有人有什么想法吗?
最佳答案
通过查看您的主机文件,您似乎没有在主机文件中提供“testy”或“fish.local”。您只需在主机文件中输入这两个域,然后就一切就绪了。
您需要像我下面那样添加它们,
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 fish.local
127.0.0.1 testy
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
希望这有帮助。
关于macos - OSX Mountain Lion 网络服务器上的 ServerAlias 无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11880415/