Jens Segers on Nov 05 2013

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

Then build the extension using the following commands:

cd php-src-PHP-5.4.17/ext/mcrypt/
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:

Step 4: Restart apache

Now just restart apache and you're done!

sudo apachectl restart


Anonymous 6 days ago

Thanks, saved my day

Anonymous 6 days ago

Thanks, saved my day

amirsys 1 month ago

Got these error msg :

Downloads/php-src-PHP-5.4.17/ext/mcrypt/mcrypt.c:407:36: error: unknown type name 'zend_rsrc_list_entry' static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC... ^ Downloads/php-src-PHP-5.4.17/ext/mcrypt/mcrypt.c:490:10: fatal error: 'ext/standard/php_smart_str.h' file not found

include "ext/standard/php_smart_str.h"

Anyone pls help..

Jomar 1 year ago

Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/ cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@23148#: Operation not permitted make: *** [install-modules] Error 1

Ahmed Khaled 1 year ago

i have some issues

Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20131226/ cp: /usr/lib/php/extensions/no-debug-non-zts-20131226/#INST@9664#: Operation not permitted make: *** [install-modules] Error 1

MarĂ­a Pilar 2 years ago

It worked like a charm! Many thanks for your work!

akarmous 2 years ago

Still have the msg Mcrypt PHP extension required.

guns65 2 years ago


RauL 2 years ago

Thanks , working in Yosemite 10.10 greetings from Mexico

ShinDarth 2 years ago

it works, thank you.

Santosh 3 years ago

This is what I'm getting after following this post:

I'm on Yosemite

nirajkmr777s 3 years ago

thanks it works for me @uptimejeff

Thank you 3 years ago

really easy way to make it work. great post

Charbel 3 years ago

I'm getting the below after make:

Downloads/php-5.4.35/ext/mcrypt/mcrypt.c:25:10: fatal error: 'php.h' file not found

include "php.h"


1 error generated make: *** [mcrypt.lo] Error 1

Tribe 3 years ago

Spendt a silly amount of time trying to fix this. 5 minutes of this tutorial and boom. Cheers son.

wazzajb 3 years ago

I have had an absolute nightmare trying to get mcrypt installed tonight, after literally hours your tutorial nailed it - thanks a bunch!

Also, the second instruction is slightly off in that 'unzip' needs changing to 'unzip'.

Thanks again!

Gerardo Camilo 3 years ago

This didn't workout for me because it kept saying that there were files missing from the downloaded zip package.

The good news is that @uptimejeff did the job. Now after hours of googling, it's working finally working!!! Thanks!!!

gsarwohadi 3 years ago

Thanks for the tutorial!

Just wanted to share my experience regarding having autoconf installed but still gives error on phpize..

I had brew install autoconf and it says it's already installed with the latest version, but after calling phpize on mcrypt directory, it always gives me the "Cannot find autoconf" error. Couldn't find any reference to what might caused this error, and after several search with no luck, I finally tried uninstalling and installing again. And it finally worked!

xoan 3 years ago

perfect explained! worked like a charm

adlag 3 years ago

Great. It worked like a charm. I needed php 5.4.24

Adam Groom 3 years ago

Thanks for that :)

Mohit Aneja 3 years ago

@uptimejeff Thanks for sharing this resource. After a long hit and trials your suggested tool finally did the trick.

Mat Bloom 3 years ago

Thank you! Success after much Googling! Cheers.

d2burke 3 years ago

Thank you!!

Sam Doidge 3 years ago

Didn't work for me, uptimejeff's downloader did

Samir Warke 3 years ago

Thanks worked perfectly!!!

Someone 3 years ago

Thanks. Worked well to get artisan running and working for Laravel :)

jeitnier 3 years ago

Worked perfectly for getting artisan running - thank you!

Kenniko 3 years ago

It's very-very helpful and made my day :D

Thanks a lot!

mixn 3 years ago

Thanks a ton! :)

Natwar Singh 3 years ago

php 5.4.17 source no longer available on given link.. you can download from here

4 years ago

Hartelijk dank Jens!

uptimejeff 4 years ago

Here is an automated mcrypt installer.. takes just a minute this way.