How to setup websites(virtual hosts) on mac using MAMP

MAMP PRO allows you to setup website directly through provide GUI (Graphical User Interface) but in MAMP (free), you will have to setup it up manually. There following 3 steps are needed to setup a local site or Virtual Host in MAMP.


  1. Setup local host first, issue the following command in Terminal (command prompt)
    sudo pico/etc/hosts

    Add a new entry at the bottom in the following form      mysitename

    mysitename can be any name that you want to choose. You will access you site by tying mysitename in URL.

  2. Edit httpd.conf. Select Finder->Go->”Go to folder”. Type /Applications/MAMP/conf/apache/httpd.conf. Open this file in your favorite text editor. I use textmate. Go to line #569 or search for Virtual hosts. Comment out the following line so that it looks like this
    # Virtual hosts
    Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
  3. Now go to https-vhosts.config, which is sitting inside the same folder in the ‘extra’ subfolder. Edit the file as the following

    <VirtualHost *:8888>
    DocumentRoot "/Users/work/Sites/MySite"
    ServerName mysitename
    ServerAlias mysitename
    ErrorLog "logs/"
    CustomLog "logs/" common

Notice that I used port 8888. The default port is 80. It is not required if you want to use default port, you can simply use * that would indicate any port.

Last thing, you should copy the following above the first virtual host that we entered above. This way you can access localhost:8888 correctly.

<VirtualHost *:8888>
DocumentRoot "/Applications/MAMP/htdocs" 
ServerName localhost 

Do not forgot to restart the webserver (both apache and mysql). Also make sure you access the site by speccing the port 8888, like this


Issue connecting to MySQL DB

I had an issue connecting to mysql DB even though the supplied username and password were correct. I fixed that by simply creating a new user, giving it all privileges, by going to privilege tab in myphpadmin:8889.


On thing I noticed when my MAMP PRO trial (15 days) expired, it deleted the database that I had created in mysql as well. Not sure if this is a bug in the MAMP PRO, but you may want to watch out for it.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s