看来最基本的虚拟主机在 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
感谢您的帮助
答案1
我卸载了 pow,并删除了 pow 安装的防火墙规则,一切运行正常。Pow 对此负责 :/
答案2
您的 pow vhost 配置定义了与您的其他 VirtualHosts 重叠的“ServerAlias *.dev”。