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


uptimejeff 5 years ago

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

5 years ago

Hartelijk dank Jens!

Natwar Singh 5 years ago

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

mixn 5 years ago

Thanks a ton! :)

Kenniko 5 years ago

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

Thanks a lot!

jeitnier 5 years ago

Worked perfectly for getting artisan running - thank you!

Someone 5 years ago

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

Samir Warke 5 years ago

Thanks worked perfectly!!!

Sam Doidge 5 years ago

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

d2burke 5 years ago

Thank you!!

Mat Bloom 5 years ago

Thank you! Success after much Googling! Cheers.

Mohit Aneja 5 years ago

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

Adam Groom 4 years ago

Thanks for that :)

adlag 4 years ago

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

xoan 4 years ago

perfect explained! worked like a charm

gsarwohadi 4 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!

Gerardo Camilo 4 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!!!

wazzajb 4 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!

Tribe 4 years ago

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

Charbel 4 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

Thank you 4 years ago

really easy way to make it work. great post

nirajkmr777s 4 years ago

thanks it works for me @uptimejeff

Santosh 4 years ago

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

I'm on Yosemite

ShinDarth 4 years ago

it works, thank you.

RauL 4 years ago

Thanks , working in Yosemite 10.10 greetings from Mexico

guns65 3 years ago


akarmous 3 years ago

Still have the msg Mcrypt PHP extension required.

MarĂ­a Pilar 3 years ago

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

Ahmed Khaled 2 years 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

Jomar 2 years 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

amirsys 1 year 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..

Anonymous 1 year ago

Thanks, saved my day

Anonymous 1 year ago

Thanks, saved my day

Emerald Hieu 1 year ago

I did everything the same but seems like it still recognizes PHP 7.1.7 which is already installed previously.

hieugioi-2:etc hieugioi$ php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20160303/' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/, 0x0009): closured error in Unknown on line 0 PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

zhirong wang 1 month ago

/php-src-PHP-5.4.17/ext/mcrypt/mcrypt.c:25:10: fatal error: 'php.h' file not found

include "php.h"


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

I couldn't download the php.h file from the link. Please help me.