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:

brew install mysql
brew install php56
brew install php56-mcrypt

Updating Apache httpd configuration

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

sudo nano /private/etc/apache2/httpd.conf

Search for rewrite_module and php5_module.

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

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so

Notice that php5_module is referencing the Homebrew version.

Starting the servers

Start MySQL this way:

mysql.server start

Start Apache this way (you will need sudo):

sudo apachectl start

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:

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

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:

sudo nano /private/etc/apache2/extra/httpd-vhosts.conf

This is a sample of my VirtualHost:

<br />DocumentRoot /Users/kahwee/projects/mcs-portal/web/
ServerName dev.mcs.com
ErrorLog "/Users/kahwee/projects/mcs-portal/web/error.log"
#CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Allow from all

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/

comments powered by Disqus