Vhosts on Mac

Here’s how to set VHosts an Mac. Mac already comes with apache, php and mysql up and running, you just may want to customize it.

Make sure you have line

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

set in your file /private/etc/apache2/httpd.conf (the mac apache configuration).
Now go to /private/etc/apache2/extra and edit file httpd-vhosts.conf.

Usuall port for http requests is port 80. In that case we’d just need to add

<VirtualHost *:80>
    ServerAdmin devel@blogaboutwhatever.com
    DocumentRoot “/Users/devel/Development/Sites/test”
    ServerName devel
    ErrorLog “/private/var/log/apache2/devel-error_log”
    CustomLog “/private/var/log/apache2/devel-access_log” common

and add server name ‘devel’ to localhost entry in /etc/hosts.

Make the vhost known in /etc/hosts localhost devel

Oh, and don’t forget to restart apache (sudo /usr/sbin/apachectl restart).

If you have a file index.html or index.php in path /Users/devel/Development/Sites/test
you should now see the related output in you browser under url http://devel.

This entry was posted in howto and tagged , , , . Bookmark the permalink.

Leave a Reply