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

link|improve this question

75% accept rate
you have to turn off the web sharing in system preferences – user76236 Mar 29 '11 at 4:48
feedback

4 Answers

up vote 8 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/

link|improve this answer
2  
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 yesterday
feedback

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

link|improve this answer
I've had no problems editing it with TextEdit – philfreo Nov 23 '10 at 20:28
feedback

Re: textedit- Depends on what’s in the user directory. Some things don’t do well with rtf; just set textedit to ‘plain text’.

link|improve this answer
feedback

Phil - I am getting closer I believe. What is the format for /Users/YOURNAME/sites/example-b ?

Does this become /Users/JoesMac/sites/joetaxpayer.com ?

When I go to local.joetaxpayer.com I get the doc folder where the web server was from original Mac settings, not the MAMP installation. When I try to change Apache to port 80 I get an error. I am running MAMP Pro, by the way, and struggling to get the multi-option working.

link|improve this answer
Yes. Make sure you have web sharing turned off in system preferences -> sharing – philfreo 2 hours ago
feedback

Your Answer

 
or
required, but never shown

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