Use Homebrew PHP with Mac OS X built-in Apache

To use the version of PHP you installed with Homebrew, you will need to change the PHP extension that Apache is loading. If you are using the built-in version of Apache this will use the built-in version of PHP even after you have installed PHP with brew.

brew install php56

You need to edit the Apache config file /etc/apache2/httpd.conf and search for libphp5.so

vimĀ /etc/apache2/httpd.conf

Then change this to point to the new brew PHP extension

#LoadModule php5_module libexec/apache2/libphp5.so
LoadModule php5_module [new-extension]

The location of the new brew PHP extension will differ depending on your setup, but you will be able to find it using brew

brew info php56

Add comment