Install mcrypt on Mountain Lion

After following my last tutorial about starting with Symfony on a new Mac, you might struggle with an extension, a few bundles need: mcrypt.

I presume you have Homebrew installed. If not, head over to my tutorial and work your way through the process.

Install mcrypt as follows:

$ brew install mcrypt

Get your PHP version with php -v:

$ php -v
PHP 5.3.26 (cli) (built: Jul  7 2013 19:05:08)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

I have PHP 5.3.26 installed. Now download your PHP here php.net/get/php-5.3.26.tar.gz/from/a/mirror (replace with your version) and extract it:

cd ~/Downloads && tar xfz php-5.3.26.tar.gz

Now compile the mcrypt PHP-extension.

cd php-5.3.26/ext/mcrypt/
sudo make install
echo "echo 'extension=\"mcrypt.so\"' >> /etc/php.ini" | sudo bash

Restart Apache sudo apachectl restart and the mcrypt extension should be installed as expected.