Setting up a virtual host on your MAMP server is not difficult.

1. Go into the Apache folder and update the httpd.conf file (/Applications/MAMP/conf/apache/httpd.conf). Don’t forget to make a backup of the httpd.conf file before editing it.

2. Look for the following line of code (Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf) and uncomment it as indicated below, don’t forget to make a backup:

# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

3. You will also have to allow override, look for the following config in your httpd.conf file and change “None” to “All”:

Options Indexes FollowSymLinks
#AllowOverride None
AllowOverride All


4. This will tell apache where to look for the virtual configuration settings. Go and edit the file of httpd-vhosts.conf as set above to the following:

  Listen 8080
  Listen 80

  NameVirtualHost localhost:80
  NameVirtualHost localhost:8080

    DocumentRoot "/example/directory"
    ServerName localhost

    DocumentRoot "/example/second/location"
    ServerName localhost

You need to add in a virtual host for port 80 “< VirtualHost *:80 >” because httpd-vhosts.conf overrides the default localhost settings. Since both of the virtual hosts are using the same server name “localhost” and separated by different ports (80 and 8080). You need to add in the “NameVirtualHost” and “Listen” command as indicated above.