Setting Up Local Virtual Hosts in MAMP
The easiest way to set up virtual hosts in MAMP is to use the commercial version of MAMP Pro, which automates & simplifies the process through the MAMP Pro console.
So if you want lovely/memorable URL's for developing locally on your Mac, here's what you have to do.
This tutorial is specific to MAMP Pro and may vary for WAMP or other local server set-ups.
MAMP Site Location
Macintosh HD ▸ Applications ▸ MAMP ▸ htdocs ▸ your-site-name
So the /your-site-name/ folder will be the place that your sites files are located.
MAMP Pro vhosts Setup
You need to give yourself a nice URL to connect to your local site in your browser, so do the following:
a) Edit the following httpd.conf file to allow the virtual hosts file to be used by MAMP:
Macintosh HD ▸ Applications ▸ MAMP ▸ conf ▸ apache ▸ httpd.conf
Around line 570, uncomment the following line:
# Virtual hosts
# Virtual hosts
b) Add a new virtual host in the httpd-vhosts.conf file:
Macintosh HD ▸ Applications ▸ MAMP ▸ conf ▸ apache ▸ extra ▸ httpd-vhosts.conf
Add the following:
c) Your Mac’s hosts file
This is only applicable to MAMP Pro - it may be different in MAMP and/or WAMP.
You do not have to find & edit your Mac’s hosts file - instead, do the following:
In MAMP Pro, you will see a tab called ‘Hosts’. Click this tab & do the following:
- Click the + to add a new host
- Give the new host a ‘Server Name’ - in this example, let’s just call it:
- local.your-site-name.dev (the same as we did in the httpd-vhosts.conf file)
- Browse to the document root and select the correct folder
Then you can browse your local site at http://local.your-site-name.dev
You're all done... happy surfing & developing locally ;-)