Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do you configure MAMP to manage/host multiple websites at one time for development?

share|improve this question
    
I don't have the reputation to comment, but I just want to point out that according to this you want to avoid editing the conf files with TextEdit: Virtual hosts with MAMP –  Yarin Nov 23 '10 at 18:11
    
I've had no problems editing it with TextEdit –  philfreo Nov 23 '10 at 20:28
    
Re: textedit- Depends on what’s in the user directory. Some things don’t do well with rtf; just set textedit to ‘plain text’. –  user73255 Mar 5 '11 at 22:52
    
you have to turn off the web sharing in system preferences –  user76236 Mar 29 '11 at 4:48

1 Answer 1

up vote 23 down vote accepted

Change your default listening port

Go to MAMP > Preferences > Ports and set Apache Port to be 80. Press okay.

Set up your local hosts file

Edit your hosts file so that you have some domains that will resolve to your local web server.

From Terminal, type sudo pico /etc/hosts and type your password. At the bottom, append the following two lines.

127.0.0.1    local.example.com
127.0.0.1    local.example.net

Save the file and exit (Ctrl+O, enter, Ctrl+X).

Add Virtual Hosts to your Apache configuration

Open up /Applications/MAMP/conf/apache/httpd.conf in a text editor, scroll down, and add the following lines to the file.

NameVirtualHost * 

<VirtualHost *> 
DocumentRoot "/Applications/MAMP/htdocs" 
ServerName localhost 
</VirtualHost> 

<VirtualHost *> 
DocumentRoot "/Users/YOURNAME/sites/example-a" 
ServerName local.example.com
</VirtualHost>

<VirtualHost *> 
DocumentRoot "/Users/YOURNAME/sites/example-b" 
ServerName local.example.net
</VirtualHost>

Restart Apache

Stop Servers and then Start Servers on MAMP. Now you should be able to visit: http://local.example.com/ and http://local.example.net/

share|improve this answer
3  
I registered in serverfault just to upvote your answer! :D –  evilReiko Jun 22 '11 at 11:23
    
Me too. This is amazing, because you don't have to buy MAMP Pro (which is kind of expensive) for managing multiple sites locally just by editing two config files. –  mav May 24 '12 at 9:34
    
For access forbidden error, go here: stackoverflow.com/questions/9110179/… –  zengr Dec 10 '12 at 19:34
3  
There is a specific file for virtual host configs located here: /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf –  Bryan Downing Mar 7 '13 at 1:11
3  
@BryanDowning It's worth mentioning that in order for apache to use this file you have to uncomment the following line from within httpd.conf file: Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf –  Big Joe Mar 13 '13 at 23:06

protected by Chris S Jun 26 at 17:51

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.