“the j stands for Johnsonese”
about me | research blog | wordpress plugins | jQuery plugins

27 October, 2016

Fixing Apache, PHP and Homebrew after upgrading to macOS Sierra


As usual, the OSX/macOS update will delete your move your old config file.
I start with the new one and make the changes I want.
In /etc/apache2/httpd.conf, uncomment the following:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

And set AllowOverride All for <Directory "/Library/WebServer/Documents">


To avoid the PEAR/PECL nightmare from last time, I want to use the Mongo PHP driver from Homebrew.

First, update to XCode 8 from App Store (4GB+ download!)
Then do this to read and agree to the license:

xcode-select --install
sudo xcodebuild -license

Homebrew then gives me a warning about the permissions of /usr/local, which are fixed with this:

sudo chown -R $(whoami) /usr/local

BUT this is slightly desctructive. We need this for MySQL:

sudo chown -R _mysql:wheel /usr/local/mysql/data

Using Homebrew’s PHP and PHP-Mongo extension

We’re going to use Homebrew’s PHP rather than the system one.

brew install homebrew/php/php56 --with-apache

This apparently installed httpd24, but I want to use the system’s Apache, so:

brew unlink httpd24

Then tell the system Apache use the Homebrew PHP. In /etc/apache2/httpd.conf:

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

Some minor configuration for our Homebrew PHP.
In /usr/local/etc/php/5.6/php.ini:

date.timezone = "Europe/Stockholm"

Then we install the Mongo driver (note I want the old mongo, not the newer mongodb) with:

brew install homebrew/php/php56-mongo

Finally restart Apache:

sudo apachectl restart