I’m trying to set up multiple virtual hosts on my local apache2 server. My goal is to be able to go to “zf2-tutorial.localhost” in the browser for my Zend project and then go to “symfony.localhost” for my Symfony project. Right now my Zend project gets served up no matter if i go to “zf2-tutorial.localhost” or “symfony.localhost”. Here’s part of my http.conf file
<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>
My “hosts” file ends with these two lines
127.0.0.1 zf2-tutorial.localhost localhost
127.0.0.1 symfony.localhost localhost
What am i doing wrong?
If you’re running Apache before version 2.3.11, then you forgot to use the NameVirtualHost directive.
You should also read up on the Apache Virtual Host documentation for version 2.2 or 2.4.