apachelocalhostvirtualhost

Apache VirtualHost and localhost


I'm working with XAMPP on Mac OS X.

I'm trying to run a Symfony website properly for a client, and I really don't know Symfony (yet). I just want to install and launch it.

I've changed my /etc/hosts file this way:

127.0.0.1 www.mysite.local

And the httpd.conf file this way:

<VirtualHost *:80>
  ServerName www.mysite.local
  DocumentRoot /Applications/MAMP/htdocs/mysite/web
  DirectoryIndex index.php
  <Directory /Applications/MAMP/htdocs/mysite/web>
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /Applications/MAMP/htdocs/mysite/lib/vendor/symfony/data/web/sf
  <Directory "/Applications/MAMP/htdocs/mysite/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

Now, the site is working (yay!), but I can't access any more any of my other local sites because localhost is rendered as www.mysite.local.

Where am I wrong?


Solution

  • This is normal if you see it. Since it is the first virtual host entry, it will show local host.

    Let’s say for example you didn't want that page to show. All you want to show is the "Apache, it works" page, so you would make a vhost entry before mysite.local as local host and point it to the "it works" page.

    But this is normal. I had this problem before, so don't worry!