If you would like to do the same, first download the most recent version of MAMP and install it locally. When you are done, you should have directories for both
MAMP PRO in your
To run the application, double click
MAMP.app inside the MAMP directory. Once it's up and running, you should see a MAMP widget with a cute elephant icon.
Let's start by adjusting the preferences. I like to run MAMP on the standard ports for Apache and MySQL. MAMP provides it's own ports, and by default uses these instead.
Change the ports. Click on the "Preferences..." button on the MAMP widget (don't ask me why it ends in an ellipsis), and select "Ports". Then click on the "Set to default Apache and MySQL ports" button (nicely named!). Click "Ok" to save your settings.
Change the PHP version. You'll need to choose the correct version of PHP for your current version of Drupal, see the complete system requirements for Drupal if you are not sure, but the following are some good general rules of thumb.
- If you are working with Drupal 8, you want PHP 5.4
- If you are working with Drupal 7, you want PHP 5.3
- If you are working with Drupal 6, you want PHP 5.2
- If you are working with Drupal 5, it's time to upgrade, but you can use PHP 5.2
You'll notice that MAMP will allow you to choose between only 2 versions of PHP (I hear MAMP PRO may give you more options). By default, the two choices you get are 5.4.10 and 5.2.17.
These options are less than ideal, one is slightly too new, and the other slightly too old. In order to use PHP 5.3 you'll need to go into
/Applications/MAMP/bin/php and rename the
php5.4.10 directory to something like
php5.4.10_x. As soon as MAMP can't find
php5.4.10 anymore, it will fall-back to the next available version of PHP, and you'll be able to use PHP 5.3 as well. You must quit and restart MAMP to see the new PHP version.
Disable caching. You'll notice in the screenshots above that MAMP automatically uses XCache for it's opcode cache. This setting may not hurt you today, or even tomorrow, but if you leave it on you'll eventually find yourself debugging something strange on a Drupal installation and after some wasted time realize that this is the culperate. Let's save you the trouble and turn that off now. From the drop-down select "--" to disable the opcode cache in MAMP.
Set up virtual hosts. Since I am often running more than one site locally at the same time, I keep them all separate by putting them in different sub-directories in my
~/Sites folder, and I map them each to a specific local domain, as defined in a virtual hosts file. The virtual hosts file for MAMP Is locaed at
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf. Here's a sampling of what my virtual hosts file looks like:
# Drupal Core
Now I'm sure there are other ways of doing this, there are probably better ways, but this works for me, and I hope it will work for some of you as well. The file above shows three separate sites. Each one has a local domain, as defined by the ServerName line. This enabled me to type http://d8core.dev into my browser to see my local Drupal 8 site.
Update the hosts file. In order for our computer to know that d8core.dev is a local site, and not to go search the web for that domain, we need to add a record into our
/etc/hosts file. Below is a sampling of my hosts file:
# DRUPAL CORE
Here, we map a local IP address to the domains as defined above. These domains could be anything you want. Use real domains like apple.com, variations on localhost, or make up your own, like I did!
Increase your PHP memory limit. The last piece of the puzzle is to make sure that PHP has enough memory to run Drupal. We'll need to find the ini files for every version of PHP we're going to use, and change some settings in each. We'll start with PHP.5.3.20. Locate the php.ini file, in my case it will be at
/Applications/MAMP/bin/php/php5.3.20/conf/php.ini. Open this file in a text editor, and search for the string "memory_limit". You'll want to increase this limit to at least
96M for any Drupal 7 site, but sometimes I do
128M just to be safe.
memory_limit = 128M
Turn on error logging. While I'm editing the ini file, I also like to turn on PHP's error logging, so that PHP errors get printed right to the screen and I don't need to dig through log files while I'm developing. The error reporting section of the ini file should be immediately following the resource limits we just changed, so it's easy to make this change at the same time as the above. Search for the string "error_reporting" and make sure it's set to E_ALL (it should be, this is the default for MAMP) and then search for the string "display_errors" and change that value from
display_errors = On
From here on out you should be ready to Drupal :)