Jens Segers on

Installing the PHP mcrypt extension on OSX 10.9

This blog post is outdated, please read this updated blog post.

The following steps will explain you how to install the mcrypt extension for the default PHP version (5.4.24) that is shipped with OSX Mavericks. You need this extension for stuff like Laravel and phpMyAdmin. Otherwise you will get this error:

Mcrypt PHP extension required.

Step 1: Install autoconf and mcrypt

I used homebrew to install autoconf and mcrypt, which is as easy as:

brew install autoconf mcrypt

If this does not work for you, or you don't want to use homebrew, then check out this tutorial.

Step 2: Build the PHP extension

To build the PHP extension you will need the PHP 5.4.17 source code that is available for download here and extract it:

cd ~/Downloads
unzip PHP-5.4.17.zip

Then build the extension using the following commands:

cd php-src-PHP-5.4.17/ext/mcrypt/
/usr/bin/phpize
./configure
make
sudo make install

Step 3: Enable the extension

All that is left is to enable the extension by editing /etc/php.ini. If this file is not present, copy /etc/php.ini.default and rename it:

sudo cp /etc/php.ini.default /etc/php.ini

Edit the /etc/php.ini file and add the following:

extension=mcrypt.so

Step 4: Restart apache

Now just restart apache and you're done!

sudo apachectl restart

Webmentions

Tweet about this blog post and you will appear below!