Working on multiple Web Projects on the same system might become a headache to manage. You must use Virtual Hosts if you are using Apache as pointed out by David Kiss. Following are the steps required to create a Virtual Host called magento in your system such that when you type http://magento the site is displayed, as per Mac OS X Lion using MAMP:
- Backup your files.
- Open a terminal window.
- Backup your hosts file:
sudo cp /private/etc/hosts /private/etc/hosts.bak - Backup your Apache configuration file:
cp /Applications/MAMP/conf/apache/httpd.conf /Applications/MAMP/conf/apache/httpd.conf.bak - Backup your Virtual Hosts configuration file:
cp /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf.bak
- Update the hosts file.
- Edit the hosts file:
sudo nano /private/etc/hosts - Add the name of the Virtual Host you want on your system:
127.0.0.1 magento - Save and exit:
Press Ctrl+X then Y.
- Edit the hosts file:
- Update the Apache configuration file.
- Edit the Apache configuration file:
nano /Applications/MAMP/conf/apache/httpd.conf - Un-comment the line where httpd-vhosts.conf is found such that it looks like this:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf - Save and exit:
Press Ctrl-W then Y
- Edit the Apache configuration file:
- Update the Virtual Hosts configuration file.
- Edit the configuration file:
nano /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf - At the end add the following:
<VirtualHost *:80>
ServerName magento
DocumentRoot /Users/fraki/Sites/magento
</VirtualHost> - Save and exit:
Press Ctrl-X then Y
- Edit the configuration file:
- Place the site contents in the folder specified.
- Navigate to the virtual host.
You might want to check the official documentation of Apache about Virtual Hosts, in this post I am using name-based virtual hosts.