I use MAMP for my local Backdrop development on MacOS.
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.
Review the PHP version. You'll need to choose a version of PHP that Backdrop supports. Currently, this is PHP 5.4 and above. I recommend using PHP 7 or above so Backdrop will be nice and fast. (See screenshot, below).
Disable caching. MAMP sometimes enables caching for your PHP files. This setting may not hurt you today, or even tomorrow, but if you leave it on you'll eventually find yourself debugging something strange and after some wasted time realize that this setting is to blame. 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. I map each site to a specific local domain, as defined in a virtual hosts file. The virtual hosts file for MAMP Is located at
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf. Here's a sampling of what my virtual hosts file looks like:
# Backdrop Core
# Client Sites
The file above shows two separate sites. Each one has a local domain as defined by the ServerName line. This allows me to type http://client.local into my browser to see the local copy of my client's Backdrop site.
Update the hosts file. In order for my computer to know that client.local is a local site, and not to go search the web for that domain, I need to add a record into my
/etc/hosts file. Below is a sampling of my hosts file:
# Backdrop Core
# Client Sites
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! (Note: I do not recommend using
.dev as a top-level-domain, as google treats that subdomain specially and Chrome may not behave how you expect.
Increase your PHP memory limit. The last piece of the puzzle is to make sure that PHP has enough memory to run Backdrop. We'll need to find the ini files for every version of PHP we're going to use, and change this setting in each. Locate the
php.ini file, in my case it will be at
/Applications/MAMP/bin/php/php7.4.2/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 Backdrop site, but I usually set it to
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
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. From here on out you should be ready to Backdrop :)