Install Apache, PHP & MySQL on macOS Sierra

Setup a MAMP local development environment on the latest macOS

MAMP refers to a Mac, Apache, MySQL & PHP stack that is typically used for local web development.

Apache and PHP are both bundled with macOS and can easily be enabled by editing a few files. MacOS however does not ship preinstalled with MySQL but setup is easy. Follow along and you’ll have a MAMP local server environment running on your Mac in no time!

TLDR: If you are impatient or would like a quicker solution without touching the command line, a MAMP GUI installer thingy can be found here:

Let's Get Started!

Open terminal and run the following command: $ sudo su -

This will allow commands to be run in the root environment so you will not have to type your password after every command. You will be prompted to enter your user account password, after typing your password, submit by hitting enter.

Note: This step is not required if you would rather, just prefix some of the commands below with sudo and enter your password when prompted.


OApache has been included with Mac OS pen terminal and run the following command see what version of apache is installed: $ httpd -v

The apache version that I have bundled with MacOS Sierra is Apache/2.4.23

Apache by default runs out of the /Library/WebServer/Documents/ directory. Ideally we want to store our websites in the 'Sites' folder under the user account. OSX Lion and later versions do not come with a default Sites folder, the Sites folder disappeared (along with the web sharing toggle in the System Preferences pane) beginning with OS X 10.8 Mountain Lion. If you need to create the sites folder manually run the following command mkdir ~/Sites or create the folder in finder under your user directory.

Note: If the sites folder exists already, no need to create a new one, simply skip this step.

Apache Config

We will need to make some changes to Apache's settings so that it works well with this setup. We can do this by opening Apache's configuration file. Feel free to use vim here if you are 1337 h@x0r.

Otherwise, we'll use nano here for simplicity, open the apache config file with the following: $ nano /etc/apache2/httpd.conf

In the examples below replace billyshall with your username.

Find DocumentRoot "/Library/WebServer/Documents" and change to DocumentRoot "/Users/billyshall/Sites"

Find <Directory "/Library/WebServer/Documents"> and change to <Directory "/Users/billyshall/Sites">

In the same block change AllowOverride None to AllowOverride All this will allow the use of .htaccess within the web server to allow overriding of the Apache config on a per directory basis.

Next we'll make sure our .php files are used as a directory index, find the following:

DirectoryIndex index.html

and change to:

DirectoryIndex index.php index.html

We'll also need to change the default user and group, find:

User _www
Group _www

and change to:

User billyshall
Group staff

Done! Save the config file with control O then press enter. Apache should be ready now, let's start it.

Start Apache

$ apachectl start

After starting apache visit http://localhost to verify apache is working correctly. you should get a "It Works!" message.

Apache is now up and running, and is ready to serve your sites.

Stop apache

$ apachectl stop

Restart apache

$ apachectl restart


PHP comes pre-installed on MacOS. to see which version is currently installed type:

$ php -v

As of OS X Sierra, the php build included is PHP 5.6.x El Capitan ships with PHP 5.5.x and OSX 10.8 Mountain Lion ships with PHP version 5.3.

Lets update PHP to the Current stable version, this is optional, but if you would like the latest stable version installed, run the following:

curl -s | bash -s 7.0

sudo cp /etc/php.ini.default /etc/php.ini


MySQL no longer comes pre-installed on MacOS as of OS X Mountain Lion (10.8) as it did with previous versions or OS X

Download the latest stable version of mysql from:

MySQL on MacOS has a GUI installer that walks you through the setup process.

After installation you will now have a new area in system preferences, here you can stop and start mySQL as well as choose to start mysql at startup.

Finished! You now have a MAMP environment setup on your Mac!

I build stuff, like Narien, the Useragent API and the Email API