# 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

Disable SIP in Mac OS. (http://www.macworld.com/article/2986118/security/how-to-modify-system-integrity-protection-in-el-capitan.html)

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.

 

Advertisements