似乎最基本的虚拟主机在 apache 2.2 下不起作用:
# httpd.conf
Listen 80
....
Include /private/etc/apache2/extra/httpd-vhosts.conf
httpd-vhosts:
# httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName project.dev
ServerAlias lol.project.dev
ServerAlias shootmania.project.dev
DirectoryIndex "app.php"
DocumentRoot "/Users/tb/workspace/project/web"
<Directory "/Users/tb/workspace/project/web">
AllowOverride All
Order allow,deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
这是 apachectl 的输出:
apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server project.dev (/private/etc/apache2/extra/httpd-vhosts.conf:21)
port 80 namevhost project.dev (/private/etc/apache2/extra/httpd-vhosts.conf:21)
port 80 namevhost pow (/private/etc/apache2/other/zzz_pow.conf:1)
Syntax OK
在我的战俘配置中:
<VirtualHost *:80>
ServerName pow
ServerAlias *.dev
ServerAlias *.xip.io
ProxyPass / http://localhost:20559/
ProxyPassReverse / http://localhost:20559/
ProxyPreserveHost On
</VirtualHost>
访问localhost
项目网站上的默认值,但访问会http://project.dev
给出 404 Not found
谢谢你的帮助
我卸载了 pow,并删除了 pow 安装的防火墙中的规则,它就像一个魅力。Pow对此负责:/
您的 pow vhost 配置定义了与您的其他 VirtualHosts 重叠的“ServerAlias *.dev”。