Install PHP mcrypt library on a Mac

Another crazy installation item. Just why I love debian so much now. But anyways, here are the steps to install the mcrypt library on a Mac. For reference, follow this link

1. Install xcode update in terminal

xcode-select --install

2. Create a temp directory for your libraries

cd ~ ; mkdir mcrypt ; cd mcrypt

3. Get the libmcrypt library from this link. The version I got was 2.5.8. Extract the tar files.

4. Check your php code by executing “php -version”. Get the php code from this link closest to your own version. In my case, it was 5.5.20. Extract the tar files.

5. Configuring libmcrypt

cd libmcrypt-2.5.8
sudo make install

With the libmcrypt configured and libraries now installed, time for to make the mcrypt extension.

6. Install Autoconf

cd ~/mcrypt
curl -O
tar xvfz autoconf-latest.tar.gz
cd autoconf-2.69/
sudo make install

7. Compile mcrypt php Extension
Move to the directory where the php code was extracted.

cd ../php-5.5.9/ext/mcrypt/

Output should be similar to:
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212

sudo make install

The result of this should be similar to:
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/

8. Enabling php Extension
Create a new file /etc/php.ini and add the following lines:

extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20121212/"

9. Restart Apache

sudo apachectl restart

10. To verify installation, execute “php –info” and look for mcrypt support. Or simply,

php --info | grep mcrypt

You should see this output mcrypt support => enabled to ensure that the library is installed successfully.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s