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
    
you have to turn off the web sharing in system preferences –  user76236 Mar 29 '11 at 4:48
add comment

3 Answers

up vote 22 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
add comment

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.

share|improve this answer
    
Yes. Make sure you have web sharing turned off in system preferences -> sharing –  philfreo May 26 '12 at 3:54
add comment

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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