How to run PHP with Apache in El Capitan

I’m assuming you like to install PHP 5.6 with MySQL and want something more than MAMP. Good news is that Mac OS X El Capitan comes with Apache so you simply have to configure it.

To begin, you will need Homebrew, if you don’t already have that, install it here.

Installing MySQL and PHP 5.6

After which, install the following packages:

Updating Apache httpd configuration

Next you will need to edit your Apache configuration. Open /private/etc/apache2/httpd.conf for that.

Search for rewrite_module and php5_module.

You have to uncomment them and change them to the following:

Notice that php5_module is referencing the Homebrew version.

Starting the servers

Start MySQL this way:

Start Apache this way (you will need sudo):

Using VirtualHost

If you’re using VirtualHost, you will need to uncomment the following line in /private/etc/apache2/httpd.conf. Search and uncomment this:

Next is to take a look at your VirtualHost file here /private/etc/apache2/extra/httpd-vhosts.conf.

To do that, you will have to do:

This is a sample of my VirtualHost:

Things to note in the above is the directory permissions. It may be different in your use case so be sure to set them properly. My project is using CakePHP is has the DocumentRoot in /Users/kahwee/projects/mcs-portal/web/