# Install HomeBrew. (https://brew.sh/)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install XCode command line tools. $code-select --install
#Install autoconf and mcrypt using brew $brew install autoconf mcrypt
The Sierra version ships with PHP 5.6.28 at the time of writing, you can always find the version from your terminal with php -v command.
Download the version source from the PHP site (http://php.net/downloads.php) and extract it.
$ cd php-x.y.z/ext/mcrypt $ /usr/bin/phpize $ ./configure $ make $ sudo make install
Make sure you enable PHP extension in apache conf and mcrypt extension in /etc/php.ini and it should all be good to go! Reenable SIP as its recommended.