Enabling mcrypt for PHP

When working on database-intensive projects, like Intelection, I sometimes use phpMyAdmin. It’s capable of using mcrypt, which is cryptographic software. However, after upgrading to Mac OS X Mavericks, my mcrypt installation was broken. I kept getting an error on printed SQL reports, and the following image would appear on each screen:

Here’s how to fix it. First, install command line developer tools so that the proper PHP libraries are in place. Use this command:

xcode-select --install

Then, download and install autoconf, which is required to install the PHP extension for mcrypt:

cd /tmp
curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar -zxvf autoconf-latest.tar.gz
cd autoconf-2.69/
./configure --prefix=/usr/local
sudo make install

Next, install libmcrypt. You can download it from sourceforge.net here. Use these commands to install:

cd /tmp
mv ~/Downloads/libmcrypt-2.5.8.tar.gz ./
tar -zxvf libmcrypt-2.5.8.tar.gz 
cd libmcrypt-2.5.8
sudo make install

The next step is to install the PHP mcrypt extension. In order to do that, you’ll need to download the correct PHP that you have installed on your system. To figure this out, run these commands:

which php --(mine showed /usr/bin/php)
/usr/bin/php -v

Go to PHP’s historical website and download the correct version. Mine’s 5.4.17. Then, install the extension:

cd /tmp
mv ~/Downloads/php-5.4.17.tar.gz ./
tar -zxvf php-5.4.17.tar.gz
cd php-5.4.17/ext/mcrypt/
sudo make install

Next, PHP must be configured to use the mycrpt extension. This is done by editing the php.ini file, as follows:

sudo vi /etc/php.ini

Use the following regular expression in vim to find the extension part of the file:


Add this line to the file:

extension = mcrypt.so

Finally, restart the web server to commit the changes:

sudo apachectl restart

With that, mcrypt is working properly again with phpMyAdmin.

Back to Top