MeuMySQL Blog is now at http://blog.mdnsolutions.com/.

Tuesday, December 4, 2012

Troubles with multiple hosts on Apache Mac OS X

Hi folks! I was running Apache on my Mac OS X, and in some point I needed to set up other virtual host for one of my projects. However everytime I've tried to access the new virtual host I was getting only the first one I had on my /etc/apache2/httpd.config. 

I sorted it out doing the steps below:


Edit  /etc/apache2/httpd.conf uncomment the vhost file like:
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

Then edit the file /private/etc/apache2/extra/httpd-vhosts.conf  adding your virtual hosts:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/Library/WebServer/Documents"
    ServerName localhost
</VirtualHost>


<VirtualHost *:80> 
  <Directory /Users/<youruser>/Sites/vhOne>
      AllowOverride All 
  </Directory> 
     DocumentRoot "/Users/<youruser>/Sites/vhOne"
     ServerName vhOne.local
</VirtualHost>

and be sure that you add to your /etc/hosts file as below:
127.0.0.1   vhOne.local
I hope it is userful. See ya around!

No comments:

Post a Comment