How to Install mcrypt for php on Mac OSX Lion 10.8 & 10.7 Development Server


The mcrypt extension is missing. Please check your PHP configuration.

The above error appears after you successfully get phpMyAdmin up and running on OS X, generally you don’t have to worry about it, you only need to address the error if you are going to use a web application that requires it, for example Magento, the shopping cart software or a php framework like Laravel.

mcrypt is a file encryption method using secure techniques to exchange data. This tutorial has been tested in 10.7 Lion and 10.8 Mountain Lion. OSX 10.9 Mavericks mcrypt guide here.

There are two ways to solve this issue on OSX, it depends on what your comfortable with and what you already have – this guide takes you through staying what you already have by installing and compiling code to get the extension running, an alternative is to use a packaged version of PHP which already has the mcrypt extension compiled and enabled, this for some would be an easier option to deploy – see that PHP guide here.



Get Xcode from the Apple app store, free download version, then install it from the /Applications folder it will be called ‘Install Xcode’ or just You need this to use the compilers to compile the source code that you will download.

Go to Xcode preferences and then look in the ‘Downloads’ button.

Install the command line tools from the preferences of Xcode.



Getting it on in OS X Mountain Lion

This tutorial works mostly in the Terminal, launch it from /Applications/Utilities, change directory (cd) to the home account and make a directory that you will work in, call it mcrypt

Get libmcrypt 2.5.8 from Sourceforge,  this is direct download link.

Get the php code in a tar.gz or .bz2 format- (version 5.3.6  – 5.3.13 are common in different builds up to OS X 10.8, 5.3.13 is current for OSX 10.8.2)

Check your version at the command line:

Move both of these files that you downloaded into your working directory – mcrypt in this instance and go back to Terminal

Expand both files via the command line or just double click them in the Finder:

Remove the compressed archives

Any errors on the command line including C++ and g++ mostly are due to Xcode not being installed or the command line tools missing – if you have Xcode but still get the errors, launch Xcode > Preferences > Downloads > Install ‘Command Line Tools’



Configuring libmcrypt

Change directory into libmcrypt
Libmcrypt needs to be configured, enter

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


Autoconf Errors

If the below error occurs after you try the following compile of mcrypt, then autoconf is not installed.

Autoconf is not installed with the latest Xcode but may be present on some OS X from an upgraded older Xcode.

If you need autoconf – some more Terminal heavy lifting:


Compile mcrypt php Extension

Output should be:
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626 warning: prefer named diversions warning: prefer named diversions


The result of this should be:

Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20090626/


Enabling  php Extension

Open /etc/php.ini and add the line below at the end

If there is no php.ini file,  then you need to make one from php.ini.default in the same location like so:

And allow write capability

Then add the line as above in your favourite text editor:


and add in the line:


Restart Apache


That’s it, check your phpMyadmin login page or create and browse to a phpinfo.php to see if it loaded correctly, if it didn’t load you may need to declare the extensions directory in /etc/php.ini



Hopefully it wasn’t too much of a nightmare…






  • Bdocsutton

    Hello Neil, That’s a great exposition, thank you, it answers a lot of questions I would have. I am already using PHP and phpmyadmin on my Mac very successfully, and had bookmarked this thread to be alerted to an answer to the mcrypt installation question (no probs other than the msg, everything else in my phpmyadmin is fine) and so I got this today.

    I do want to use PayPal security now, and now that you have published this “how-to” I’d like to complete the phpmyadmin installation with mcrypt.

    So – one query on your mcrypt installation workflow, probably exposing my unfamilarity with the Mac, as a recent convert from Windows (and luvvin’ it); since I am already using PHP and phpmyadmin, where should I do the mcrypt downloading and compilation? I guess the php.ini tells PHP where to look, but since you talk about creating a new mcrypt folder where your mcrypt AND PHP DOWNLOAD are stored, I won’t have the PHP part to do. E.g. do I have to compile the mcrypt download into any existing php or phpmyadmin folder, or can it be anywhere and/or just in its own folder like other applications?

    That’s it – I’m generally aware there is no such thing as a quick or stupid question since very often the answer can be a lot longer than the question. If I have achieved a rare stupid question result, apologies!

    Best regards, and then you already for the current thread,


    • Neil Gee

      Hi Brian, the folder can be anywhere and is a temporary holding spot for the source files, after the process is finished can be removed.

      • Bdocsutton

        Hi Neil,
        I should have replied sooner but i had a University delivery trip that intervened! The mcrypt installation went fine (once I had the presence of mind to install the  Xcode I had downloaded, all 2 Gig of it! – ./configure couldn’t be found without it) Of course on a re-read I should have realised the download folder can be anything; also that even though I already have it, PHP has to be downloaded (but not installed) whiolesale so that the ../php-5.3.6/ext/mcrypt/subfolder can be found and installed. Like I said I’m a Mac newbie and the Terminal command line technique is new to me having not been Unix person.Thanks again – you probably wonder how “ordinary” people manage; it’s buy finding guys like you, of course!Best, Brian

  • Neil Gee

    it might not be there, if its not make a copy of ‘etc/php.ini.default’ name it php.ini and leave it in /etc

    • Reed

      Did as you suggested.  Then used 2nd method above (declared the extensions directory in /etc/php.ini).  mcrypt is installed.  Thank you!

  • Anonymous


    I followed these instructions, but now I even get more of these mcrypt-error messages.

    See this screenshot:

    Any idea on where I might have gone wrong / what the error can be ? 


    • Neil Gee

      have you tried the extensions directory declaration as in the bottom of the post?

  • Bodger

    Perfect series, thanks! 
    And good luck with your rankings!

  • Fgoellner

    Thanks for this great series of instructions. Followed carefully up to
    cd ../php-5.3.6/ext/mcrypt/ Ended up with ../ext – there is no file called mcrypt.Please help!

    • Neil Gee

      its a directory and is in /php-5.3.X/ext/mcrypt/ – take a look from the finder view

      • Fgoellner

        It’s not. I looked from the finder and have no idea. In ext/ is …, ldap, libxml, mbstring, mssql, mysql, mysqli, mysqlnd, …
        I followed all the instrructions carefully and everything else worked as it should. The only difference I can think of is that I installed the most actual version of xcode (Version 4.2.1 (4D502)).
        Before, I followed the istructions to set up AMP with Lion and after that phpmyadmin. Everything went well up to this missing directory mcrypt.
        Thanks for your help!

        • Neil Gee

          re-download php-5.3.6.tar.gz and expand it and look again 

          • Fgoellner

            Thanks for all your help!
            Yes, there it was. I continued up to the result of: Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20090626/But in /etc is no php.ini  I found php.ini.default, which I changed as in your instruction. But after restarting several times apache, mcrypt is still not included. There is another file called php.ini.default-5.2-previous in /etc.Please help again.

          • Neil Gee

            have you declared the extensions directory in php.ini as stated in the post?

          • Fgoellner

            I declared it in php.ini.default because there is no php.ini in /etc – only ‘php.ini.default’ and ‘php.ini.default-5.2-previous’

          • Neil Gee

            what you have to do is make a copy of php.ini.default and name it php.ini and then it should be ok…..

            sudo cp /etc/php.ini.default /etc/php.ini

            then restart apache

            sudo apachectl restart

          • Fgoellner

            That was it!
            Thanks a great lot!

  • Sarah German

    Great writeup, thanks!

  • guest

    It worked for me! Thank you!

  • Neil Gee

    you don’t have to use the php version which you have installed the earlier versions 5.3.5 and 5.3.6 definitely work regardless if you have a later version on your OS, to clean up just remove the source folder where you downloaded the 2 packages into

  • Rob Ganly

    Thanks, worked perfectly.


    Rob Ganly

  • Neil Gee

    it doesn’t show that way in mine either but it is loaded try a phpinfo.php file with –

    Then do a find for mcrypt

  • Neil Gee

    is Xcode installed?

    • Wch70

      I get the exact same thing as vd5283. I do have Xcode installed.

      • kedi
        • Wch70

          I am very new at this and barely have any idea what I’m doing with this stuff. Thank you for your suggestion kedi, that did get me a little further along, as I did have to install the Unix Command Line Tools. But now I have another issue. When I enter the line  /usr/bin/phpize I get a new error and I have no idea how to fix it: 
          ==================================================Configuring for:
          PHP Api Version: 20090626
          Zend Module Api No: 20090626
          Zend Extension Api No: 220090626
          Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.==================================================Any help is greatly appreciated. I’ve been at this for a good while and I’m quite frustrated at this point. This all started from trying to set up a local dev environment on my Mac. Something I thought would (should) be simple has turned into a nightmare that’s eaten up days of my life.

          • Onefine

            I had exactly same problems as you Wch70. We are missing autoconf installation. This copy/paste to terminal, and it will install it. Then you could continue.. On this link is code:

  • ksnj

    Thank you. This worked like a charm.

  • Yang

    Very great! thank you very much!
    I have some questions.does directly using MAMP have any differences than this way approaching AMP server?
    speed security &ect?

    • Neil Gee

      not really – you may need to use separate port numbers and is not advisable to run both simultaneously

  • Jon

    Hello, followed all of your instructions but got to:

    Open etc/php.ini and add the line below at the endwhich etc folder is this? There’s hundreds of them on my computer. I’ve also done a search for php.ini.default and that does not exist anywhere on my computer.


    • Neil Gee

      Use the Go menu in the Finder – > Go To Folder… and type in /etc

  • Fefloors

    Hi Everyone,

    I’ve come across a problem. When I enter;

    /usr/bin/phpizeI get the following response.
           Configuring for:

           PHP Api Version: 20090626

           Zend Module Api No: 20090626

           Zend Extension Api No: 220090626

          Cannot find autoconf. Please check your autoconf installation and the

    $PHP_AUTOCONF environment variable. Then, rerun this script

    I have installed xcode 4.3.2 (along with the command line tools) and I can’t seem to find an answer for this problem.

    Any help would be greatly appreciated


    • onefine

      I have same problem.. :(

  • Pingback: Como instalar mcrypt para php en mac osx mountain lion10.8 para tu localhost « El Blog de JcPy()

  • Pingback: 在Mac OS X中配置Apache + PHP + MySQL @ 随网之舞()

  • Pingback: 在Mac OS X中配置Apache + PHP + MySQL | Software MyZone()

  • Pingback: Pow with Laravel — Josh Betz()

  • Pingback: 在Mac OS X中配置Apache + PHP + MySQL(转载) | 栀子花开()

  • Pingback: Mac搭建PHP环境:Apache + PHP + MySQL | 灵龙-技术 实验室()

  • Pingback: PHP – Kohana Framework Tutorial – Teil 1 | Blog der Zoom7 GmbH()

  • Pingback: Why I hate mcrypt for Macs | King Luddite()

  • Pingback: Mac OS X中配置Apache + PHP + MySQL - eureka - android/ios/网站/创业()

  • Pingback: MacでもOpenCartを動かしたい(テスト用で) | NAOMO()

  • Pingback: Installare la libreria mcrypt per PHP su Mac Os x |

  • Pingback: Installer mcrypt sous mac OS X 10.8 &… | #NPPT()

  • Pingback: 让Mac OS X中的PHP支持mcrypt | show的博客()

  • Pingback: Charlotte Genevier » Blog Archive » Using Laravel on OSX – MCrypt Extension Installation()

  • Pingback: laravel4 installation: can't get rid of damn errorCopyQuery CopyQuery | Question & Answer Tool for your Technical Queries,CopyQuery, ejjuit, query, copyquery,, android doubt, ios question, sql query, sqlite query, nodejsquery, dns q()

  • Pingback: Installer Mcrypt sur Mac OS X Lion, Mountain Lion etc | Sum Daniel // Web Developer PHP, HTML in BrusselsSum Daniel // Web Developer PHP, HTML in Brussels()