Configure multiple virtual hosts on apach2 local mac

I am trying to set up multiple virtual hosts on my local apache2 server. My goal is 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 is served whether 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?

+3


source to share


1 answer


If you are using Apache before 2.3.11 , you forgot to use NameVirtualHost .

NameVirtualHost *:80

      



You should also read the Apache virtual host documentation for version 2.2 or 2.4 .

+3


source







All Articles