Like it or not, MAMP is an excellent tool for local development. If you work on multiple sites or projects at the same time across different frameworks and or CMS’s then MAMP will make your life simple. This MAMP development setup is what I have used for years while working on many freelance projects, personal projects, and obviously the day to day work projects.
In my opinion things like Vagrant and Docker have their place but tend to overcomplicate and slow down local development. If you like Vagrant and Docker then keep at it. But consider being responsible for 40 different sites, all with various changes and updated. Good luck!
Some MAMP pros include all local sites being accessible at the same time, simple MySQL administration with PHP MyAdmin or Sequal Pro.
But some of the negatives can come once you have made changes to various config files and then go to update MAMP or add newer versions of PHP. Sometimes your configs will break, and MAMP is not setup like your Ubuntu VPS, things are not in the same locations. Most Unix commands won’t work ( Thanks, Apple ).
But as you become more and more familiar with MAMP it’s not all that bad. In fact, I think it’s the best option going.
Install MAMP 4:
Setup your document root.
Set the Web Server to Apache
Set the Document Root to
~/Sites Or where ever you keep your PHP projects.
Setup your VirtualHosts
Open and edit
/Applications/MAMP/conf/apache/httpd.conf Search for DocumentRoot Change the path to
# Virtual hosts and uncomment the line ( delete the # )
Create an entry in
<VirtualHost *:80> DocumentRoot "/Users/yourusername/Sites/mydomain.ca" ServerName mydomain.local </VirtualHost>
Enable PHP 7
$ brew install memcached
Launch Memcached when the computer starts.
$ ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents
Enable Memcached with PHP.
; Extensions and uncomment
Install Redis (Optional):
$ brew install redis
Launch Redis on computer starts.
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Start Redis server via “launchctl”.
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Test if Redis server is running.
$ redis-cli ping
If it replies “PONG”, then it’s good to go!
Start Redis server using configuration file.
$ redis-server /usr/local/etc/redis.conf
Stop Redis on autostart on computer start.
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Location of Redis configuration file.
Uninstall Redis and its files.
$ brew uninstall redis $ rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Get Redis package information.
$ brew info redis
Setup MAMP 4:
Enable short tags
While WordPress coding standards wont allow short tags to be enabled… Who really has time for that.
short_open_tag = On
Download the Reis extension:
Copy redis.so from the appropriate subdirectory of this repo to
/Applications/MAMP/bin/php/php5.x.x/lib/php/extensions/no-debug-non-zts-200xxxxx (Channge to your PHP version)
; Extensions and Enable Memcached and Redis extensions.
Enable Xdebug at the bottom of the file by Deleting the ; . It should already be there but will be commented out.
Configure your local DNS (Optional)
The Mac OS hosts file will not allow us to use wildcard subdomains, To get around this we can use a local DNS Proxy called DNSMasq.
brew install dnsmasq
The configuration is stored in
Inside add the following line.
This will tell any request coming in at *.dev to use our local IP.
Load DNSMasq at start
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
Start and Stop
sudo launchctl stop homebrew.mxcl.dnsmasq sudo launchctl start homebrew.mxcl.dnsmasq
We now need to configure our mac OS to use the new local DNS server.
To do this, Go to System Preferences and then Network. For DNS configuration add your local IP 127.0.0.1 first followed by your usual DNS IP addresses:
127.0.0.1 22.214.171.124 126.96.36.199
To confirm that this is working, ping a local .local site.
$ ping test.local PING test.local (127.0.0.1): 56 data bytes
Every now and then I come back to this article to get things setup for myself or co-workers. Since writing this MAMP 5 has come out and there are some small updates. You can read more about them here