Setting up MAMP 2 on OSX – Leopard & Snow Leopard
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.
- Once you have your download, go to System Preferences and switch off Web Sharing. (Sharing pane.)
- 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.
- 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 .
- 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:
- 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:
- Restart MAMP and you should be good to go.
- 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:
then add your version of the following:
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.
- 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.)
- Amend the file at line 7 so it reads:
127.0.0.1 localhost yoursite.local
and restart MAMP.
- 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!other page