Mac Apache VirtualHost Configuration

Today morning Dinesh showed me a project on MAMP pro which helps us to manage different virtualhost on mac. I installed the application and it was pretty cool. The annoying with MAMP was it had its own http and mysql server. It was bit annoying since it was not using the native webserver and it was using old version of php :-(. So I sneaked around and found what are the changes it is doing to make virtualhost work in mac.

Its the same old school trick. I added two virtual host to my machine namely

  • imthi.macimthi.local
  • wordpress.macimthi.local

To make this work I have basically edit two files

File 1 – /etc/host

To this file add these two lines to end and save it.

127.0.0.1 imthi.macimthi.local
127.0.0.1 wordpress.macimthi.local
File 2 – /etc/httpd.conf

Add the following lines to end and save it.

NameVirtualHost *:80

<virtualhost *:80>
ServerName imthi.macimthi.local
DocumentRoot “/home/imthi/public_html”
<directory “/home/imthi/public_html”>
Options Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</directory>
</virtualhost>

<virtualhost *:80>
ServerName wordpress.macimthi.local
DocumentRoot “/home/wordpress/public_html”
<directory “/home/wordpress/public_html”>
Options Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</directory>
</virtualhost>

Thats it. Once these changes are made restart your webserver and both the urls are ready to rock and roll. 😀

Published
Categorized as Personal

By Imthiaz

Programmer, SAAS, CMS & CRM framework designer, Love Linux & Apple products, Currently addicted to mobile development & working @bluebeetle

3 comments

  1. I did this exactly on my macbook pro with MAMP and it’s not working. I wonder what I am doing wrong

Comments are closed.