I don't use MAMP, but I have done the same thing using the pre-installed Apache 2. There may be a simpler way to do this, but this has really helped me with testing multiple sites in my local machine.
Edit host file
The host file is located at /etc/hosts
. I end all of my local test domains with local
, but this isn't required. Here's a sample of what I have.
# clients
127.0.0.1 acmewidgets.clients.local
127.0.0.1 someclient.clients.local
127.0.0.1 etcetc.clients.local
# Projects and mini sites
127.0.0.1 someproject.proj.local
127.0.0.1 someotherproject.proj.local
# tools
127.0.0.1 sql.tools.local
# Different open source solutions
# e-commerce
127.0.0.1 magento.apps.local
127.0.0.1 opencart.apps.local
127.0.0.1 oscommerce.apps.local
127.0.0.1 zencart.apps.local
# forums
127.0.0.1 vanilla.apps.local
# blogs
127.0.0.1 wp.apps.local
127.0.0.1 wpmu.apps.local
# CMS's
127.0.0.1 joomla.apps.local
127.0.0.1 drupal.apps.local
127.0.0.1 concrete5.apps.local
So not only do I have different client sites, but you can see that I have a subset of open source platforms that I routinely use and test against, as well as personal projects and tools.
Also, note that it's not a good idea to replace localhost
, as some other applications are likely to use it. You should just add
Edit virtual hosts
Again, I don't use MAMP so I don't know where it's stored, but you're looking for the http-vhosts.conf
file. In the standard OS X install, it's located at /etc/apache2/extra/httpd-vhosts.conf
For every *.local domain that I've created in my host file, I've created a respective virtual host entry.
NameVirtualHost *:80
# Open source app testing
# ----------------------------------------------------------------------
<VirtualHost *:80>
ServerName opencart.apps.local
DocumentRoot /Users/justin/Development/localhost/opencart/html
</VirtualHost>
<VirtualHost *:80>
ServerName oscommerce.apps.local
DocumentRoot /Users/justin/Development/localhost/oscommerce/html
</VirtualHost>
# Tools
# ----------------------------------------------------------------------
<VirtualHost *:80>
ServerName sql.tools.local
DocumentRoot /Users/justin/Development/localhost/bin/tools/wwwsqldesigner
</VirtualHost>
* You may have to change the permissions on either of these files to be able to save your changes.