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


Jomar 6 months 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 7 months 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 1 year ago

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

akarmous 1 year ago

Still have the msg Mcrypt PHP extension required.

guns65 1 year ago


RauL 2 years ago

Thanks , working in Yosemite 10.10 greetings from Mexico

ShinDarth 2 years ago

it works, thank you.

Santosh 2 years ago

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

I'm on Yosemite

nirajkmr777s 2 years ago

thanks it works for me @uptimejeff

Thank you 2 years ago

really easy way to make it work. great post

Charbel 2 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 2 years ago

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

wazzajb 2 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 2 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 2 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 2 years ago

perfect explained! worked like a charm

adlag 2 years ago

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

Adam Groom 2 years ago

Thanks for that :)

Mohit Aneja 2 years ago

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

Mat Bloom 2 years ago

Thank you! Success after much Googling! Cheers.

d2burke 2 years ago

Thank you!!

Sam Doidge 2 years ago

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

Samir Warke 2 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

3 years ago

Hartelijk dank Jens!

uptimejeff 3 years ago

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