Setting up MAMP 2 on OSX – Leopard & Snow Leopard

7 Comments

Here is a quick guide for setting up MAMP (Mac, Apache, MySQL and PHP) on OSX. I used this on Leopard and have just set it up again on Snow Leopard.

This has been updated (20 July 2011) to include MAMP 2.0 in readiness for Lion.

First up, download a copy of MAMP from here: MAMP website. They offer a free version and a PRO version, which has a better GUI and lets you run multiple Virtual Hosts amongst other things. I will explain how to set this up on the free version later.

  1. Once you have your download, go to System Preferences and switch off Web Sharing. (Sharing pane.)
  2. Double-click the MAMP installer and drag the icon to the Apps folder to install it. It offers a free trial of MAMP PRO but go with the basic version.
  3. You need to enable the root user for phpMyAdmin, so go to System > Library > Core Services > Directory Utility. Next go to theEdit menu > Enable Root User and enter a password .
  4. Next, change the default MAMP settings by starting MAMP, opening the control panel and click the Preferences button. Go to the Ports tab and change the entries to 80 and 3306 as shown here:

    MAMP Ports

    MAMP Ports

  5. I like to change the MAMP settings so files are served up from my Sites folder rather than the default MAMP htdocs folder. To do this, go to Applications > MAMP > conf > apache and open the http.conf file in a text editor. Go to line 368 (in MAMP 2.0 this is line 187) and comment it out, then add a new line like this: DocumentRoot “/Users/yourname/Sites”. I comment it out to keep the original reference handy! Do the same thing at line 394 (MAMP 2.0 line 212) adding the same path as before:
    .
  6. Restart MAMP and you should be good to go.
  7. If you like to work with php includes (see this post) then you need to set up Virtual Hosting. Go back to your http.conf file in step 5 and scroll way down to the bottom. Un-comment and edit the last line so it looks like this:
    NameVirtualHost *:80
    then add your version of the following:

    DocumentRoot “/Users/yourname/Sites”
    ServerName localhost

    DocumentRoot “/Users/yourname/Sites/yoursite”
    ServerName yoursite.local
    In MAMP 2.0 around line 522 you’ll see the Virtual hosts line with this commented out:#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.confI left it and added the code shown above and everything is working as expected.
  8. Finally, we need to edit the hosts file. Click on the Finder > Go > Go to Folder… and type /etc so you can open the hosts file in a text editor. (You will need to authorise this by typing in your password.)
  9. Amend the file at line 7 so it reads:
    127.0.0.1 localhost yoursite.local
    and restart MAMP.
  10. If you use Dreamweaver, go to Manage Sites, select your site and click the Edit button. Click on the Testing Server Category and for the URL Prefix, type: http://yoursite.local/

That’s it. Once MAMP is running, you can type the address at step 10 into the address bar of your browser and admire your website!

MAMP , , , , ,


7 Comments

  1. dcolumbus

    Hey Stuart,

    Thanks for the post. I’m not sure why, but Lion doesn’t seem to be cooperating … my host file is fine and so is my httpd-vhosts.conf … is there something else that would prevent “mydomain.local” from working correctly?

    • Stuart

      Sorry for the delay – I’ve been away.
      It may sound obvious, but sometimes a restart of the whole system will get this working. If all your http.conf and hosts files are fine then everything SHOULD work… Even MAMP restarts are not infallible.

  2. Veronique

    Thank you so much! I’ve been looking for days for a solution on all kinds of sites and posts, because mydomain.local wasn’t working correctly. You solved my problem!

    • Stuart

      Glad to help!

It's good to talk!

Your email address will not be published. Required fields are marked *

Please answer before submitting form * Time limit is exhausted. Please reload CAPTCHA.