我正试图在本地apache2服务器上设置多个虚拟主机。我的目标是能够在浏览器中为我的Zend项目转到"zf2tutorial.localhost",然后为我的symfony项目转到"symfonylocalhost"。现在,无论我是转到"zf2 tutorial.localhost"还是"symfony.local",我的Zend项目都会得到服务
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot /Users/myusername/Sites/Zend/public
SetEnv APPLICATION_ENV "development"
<Directory /Users/myusername/Sites/Zend/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName symfony.localhost
DocumentRoot /Users/myusername/Sites/symfony
SetEnv APPLICATION_ENV "development"
ServerAlias www.symfony.localhost
</VirtualHost>
我的"主机"文件以这两行结尾
127.0.0.1 zf2-tutorial.localhost localhost
127.0.0.1 symfony.localhost localhost
我做错了什么?
如果您运行的是2.3.11版本之前的Apache,那么您忘记了使用NameVirtualHost指令。
NameVirtualHost *:80
您还应该阅读Apache虚拟主机2.2或2.4版的文档。