MAMP is a simple to use tool and is often a staple in a WordPress developer’s tools. When you start, you only have a single “domain” http://localhost/ making working on multiple local sites a bit of a problem. Additional sites can be added by adding virtual hosts, this can seem a bit daunting if you’ve never done it before, but is actually quite simple.

The Hosts File

A hosts file can be used to point requests for a domain to an IP address, by creating a virtual host it can tell our device our domain is hosted locally, not online.

To edit the hosts file, open up Terminal and type the following:

sudo nano /etc/hosts

sudo simply means to execute the command as root, nano is the text editor we’ll be using and /etc/hosts/ is the location of the hosts file. You’ll be prompted for your OS X password (a administrative password is required when using root.)

You’ll then be presented with a file where the bottom few lines look something like this:       localhost broadcasthost
::1             localhost is is an IP address that refers back to the local device, it’s how a computer refers to itself.
Disclaimer: Don’t remove any existing entries to your hosts file, bad things will happen!

To add your local domain simply enter followed by your domain, for example:

Tip: Avoid domain names with .local on the end as this can cause issues with Bonjour.

When you’re done press Ctrl-O, enter, then Ctrl-X followed by enter again (this saves the file and closes the editor.)

The Apache Config File

We’ve successfully told our device that our domain is local, but we still need to point our web server (Apache, it’s the A in MAMP) at the right directory (where the files are stored) for our site.

To do so, we need to edit our Apache config file stored here:


Open it with any text editor, scroll all the way to the bottom and add the following:

<VirtualHost *>
DocumentRoot "directory"
ServerName domain

Replacing directory with the path to the file for the site and domain with the domain we added to hosts earlier, for example:

<VirtualHost *>
DocumentRoot "/users/josh/sites/myawesomesite"

Save the file and you’re done! Start up MAMP and enter your domain in your browser. You can simply rinse and repeat these steps to add as more sites…