Plugging mcrypt into PHP, on Mac OS X Snow Leopard 10.6.1

First mcrypt on Leopard, and now we ready for the winter cat. Additionally, special thanks goes out in advance to commenter Yvan Barthelemy (a.k.a. ybart) for cluing me in here. The procedure is almost exactly like the previous…almost. So pay attention.

The following instructions cater to those who a) are developing on OS X Snow Leopard 10.6.1, b) need the capabilities provided by mcrypt during their PHP development, and c) do not want to completely recompile PHP to get there. You’ll get mcrypt loading dynamically for use in PHP with this method.

First, you are going to need a few things…

1) libmcrypt-2.5.8, which you can pick up here; NOTE: make sure to get libmcrypt and not mcrypt.

2) PHP 5.3.0 source, which you grab here; ADDITIONAL NOTE: You may have already updated your OS X beyond 10.6.1, and PHP may have been updated along with it. In this case, use phpinfo() to check your version of PHP, and then download the PHP source for that version. Thanks to commenter Blair for suggesting this note;


3) Xcode 3.2 tools, which you can pick up here (Apple Developer Connection membership required).

Next, create a directory at root called ‘SourceCache’ and dump the files from #1 and #2 in there and unwrap.

Move to the libmcrypt-2.5.8 directory, and punch in this…

MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --disable-dependency-tracking

and then…

make -j6

and finally…

sudo make install

libmcrypt is ready – now for the PHP extension…

Move back to /SourceCache, then down to php-5.3.0/ext/mcrypt – type…

/usr/bin/phpize (phpize should be in /usr/bin – if not go find it and change the command as appropriate)

Then configure as follows…

MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Developer/SDKs/MacOSX10.6.sdk/usr/bin/php-config

Again make -j6 then sudo make install

Make sure you have php.ini in the /etc directory (it will probably be php.ini.default to start, particularly if you’ve just done the Snow Leopard upgrade, so rename it). Ensure that enable_dl = On but do not remove the ; from in front of ;extension_dir = "./". Add one line to the .ini file in the Dynamic Extensions section…

Restart Apache – you should be all set (again), according to phpinfo():

BIG NOTE: As the substantive content of this guide has aged a number of new releases have come out, including but not limited to patches for Snow Leopard. As a result, PHP versions have changed, XCode has been updated, and more. If you come across quirks during your attempts to get mcrypt working, please read the comments before detailing your problem, as many of those issues have been solved. Finally, thanks go out to all of the folks who have contributed – it is greatly appreciated by all!


SanchonX says:

Thanks so much for this, very easy to follow and worked a treat!

jim says:

Perfect! Thanks so much. Worked a treat!
Will this work for all extensions or are there some that shouldn’t be loaded dynamically?

Jim – I think that depends on a whole lot of factors, but I’ve been able to compile everything I ever needed. But the latest build of PHP includes quite a bit more in the way of vanilla stuff, so I think you’d have to evaluate on a case by case basis.

Donna says:

Michael, you are AWESOME! I had found some other instructions that had me dreading this process. You made it so easy. Everything worked first time just as you said. Wish I could buy you lunch; you’ve surely earned it. 🙂

Thanks for that Donna! And I’ll note I had help, and thank them again.

Martijn says:

Excellent! Finally something that worked.
Thanks for the clear descriptions.

Derek says:

it worked like a charm… Thank you.

Bryan says:

Hmmm. Didn’t work for me. The second (mcrypt) configure ends with a notice about the ‘–with-php-config’ directive being not understood. Then the make -j6 fails with the error…

make: *** [sapi/cli/php] Error 1
make: *** Waiting for unfinished jobs….
lipo: can’t open input file: /var/folders/tT/tTPfGpLBF1iLIoatrRVNC++++TI/-Tmp-//ccIMOVtx.out (No such file or directory)
make: *** [sapi/cgi/php-cgi] Error 1

There may or may not be related. But that;s where the trail ended for me sadly.

Incidentally, the php-config binary is in the /Developer/… folder where it should be.

Thanks for any help. 😀


Bryan says:

Oh… this is more likely the useful part of the error above…

ld: duplicate symbol _spl_ce_SplDoublyLinkedList in ext/spl/spl_dllist.o and ext/spl/php_spl.o for architecture i386
collect2: ld returned 1 exit status


Bryan says:

Ah crap. OK. Ignore me. I’m stupid. LOL Went back and started again and this time it worked. (long story). Feel free to “reject” (moderate) all these noisy comments too btw. 😛


Michael Tupper says:

So, it would have been helpful to know what you did differently here! Apparently I’m stupid too, even more so, as I got to the exact same point with the same error type, but haven’t been able to resolve yet. What am I missing?

Michael Tupper says:

Got it… same problem as Sinek Dragi (from Aug 20, 2011 – below).

Was using wrong ver of php — had 5.3.6 already installed and was doing this with 5.3.0

Rejection is not an acceptable word here Bryan. Glad it worked out for you, and hope others can learn from the (obviously) tiny mistakes that make these little tutorials so darn aggravating.

PS: @Martijn, @Derek: You are welcome!

Luis Rosety says:

I followed your instructions but I get the following:

checking for libmcrypt – version >= 2.5.0… no
*** Could not run libmcrypt test program, checking why…
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means LIBMCRYPT was incorrectly installed
*** or that you have moved LIBMCRYPT since it was installed. In the latter case, you
*** may want to edit the libmcrypt-config script: no
configure: error: *** libmcrypt was not found

I am starting with Mac and I have no experience with Unix nor Linux.
Maybe I am doing something wrong…

Looks like you don’t have libmcrypt installed. When folks were working with Leopard, some noted similar errors and had installed mcrypt, not libmcrypt. The package you need comes from the source “libmcrypt-2.5.8.tar.gz”.

When in doubt, delete all source and try again.

Magnus von Bromsen says:

Hello MG and thanks for a tutorial that seems easy enough even for me to follow. 🙂

But, I run into a little problem: when running the first “make -j6” I got this error:
-bash: make: command not found

I’m inside the libmcrypt folder when trying. Any idea how to solve that?

Regards, Magnus

Hmm…path issue? Try ./make

If that doesn’t work, try switching the shell back to default login (under preferences, if you’ve got it set to command complete path).

Just troubleshooting ideas.

Magnus von Bromsen says:

Hi again
I tried with “./make -j6” but that gave me another error:
-bash: ./make: No such file or directory

I’m using the default login. Can this have something to do with that I got a lot of “checking … … no” when I run the first command? Like this:

checking host system type… i686-apple-darwin10.0.0
checking target system type… i686-apple-darwin10.0.0
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for gawk… no
checking for mawk… no
checking for nawk… no
checking for awk… awk
checking whether make sets $(MAKE)… no
checking whether to enable maintainer-specific portions of Makefiles… no
checking whether make sets $(MAKE)… (cached) no
checking for g++… no
checking for c++… no
checking for gpp… no
checking for aCC… no
checking for CC… no
checking for cxx… no
checking for cc++… no
checking for cl… no
checking for FCC… no
checking for KCC… no
checking for RCC… no
checking for xlC_r… no
checking for xlC… no
checking for C++ compiler default output file name… configure: error: C++ compiler cannot create executables
See `config.log’ for more details.

Regards, Magnus

Magnus von Bromsen says:


I just found out that I had only Xcode 3.1.2 (I was absolutly sure that I had 3.2). I will come back after I tried it with the right version.

Sorry 🙁

— magnus

Magnus – the XCode version shouldn’t have made that much of a difference, but from the looks of the above I would have guessed you didn’t have the developer tools installed at all.

Magnus von Bromsen says:

I’m so stupid!
Everything solved after updating Xcode 🙂

Really sorry.

Regards, Magnus

Magnus von Bromsen says:

Well, maybe it was I had an updated SL (from Leopard). Some setting was wrong or missing…

But, now I’m happy 🙂
And many, many thanks for this guide (now I can install Magento 1.4 for testing).


I take that back. The old Xcode wouldn’t have had the 10.6 dev environment.

Thanks so much for the great tutorial. This worked like a charm.

This helped. Thanks! 🙂

@Paul/Muhammad – No prob. Glad it worked out for you.

Jason says:

Thanks for the walk-through – works great! I got the same error as Luis Rosety’s error, btw. The reason is exactly as you said, however what you were saying wasn’t registering at first. The download link provided for libmcrypt has source for both mcrypt and libmcrypt. The highlighted download at the top of that page is for mcrypt, though. You have to look below to fine the libmcrypt source. It would have helped me if you put a little note next to that step that says “make sure to get libmcrypt and not mcrypt!” I know it’s a silly mistake, but that download page makes it appear that you should be downloading mcrypt.

[…] everything that I need except mcrypt.  Luckily Michael Gracie has provided a walk-through for installing mcrypt on Snow Leopard which involves re-compiling some things, but isn’t as tough as it first […]

David says:

As others have stated, the steps are very clear, and worked the first time through flawless. Thank you for taking the time to write this up.

billd says:

perfecto! thanks

crucco says:

Hi, that was a nice try like all other advices on the web. I was too new with 10.6.2 everything seemed to work out fine. But now PHP isn’t working anymore….

crucco – Do you mean Apache won’t start?

crucco says:

it means that its impossible to create a php.ini file instead of php.default.ini and make that timezone-warnings pass because
on 10.6.2 php refuses to run with php.ini file. it works only on php.default.ini and you can’t change anything because all remains default.. apple developers change to much on that and without any clue what serves web-developers … grmpfff

crucco – PHP is still the same build, 5.3.0, on 10.6.2. I’ve done the update, and everything is still working fine (including the mcrypt). Are you certain you don’t have a permissions issue?

UPDATE: I just checked my install, logged in as root. I have php.ini and php.ini.default, and full control over them. Just for shits and giggles, I bak-ed the ini file, copied and renamed php.ini.default (to php.ini), added the extension reference, and restarted Apache without issue.

crucco says:

Hi Michael,
was thinking about rights. checked all and changed it php.ini’s owner is root and the group is wheel. repaired all rghts with disk utility booting off a cloned system, tried everything. But, when there is a php.ini phpinfo won’t show anything and php doesn’t work. when php.ini is deleted and ther’s only the php.default.ini everything works. but also if you set the date_timezone in that file all remians defult. So the only clue for me now is that is has something to with 10.6.2 snow leopard update. I can’t tell what was before because I started a fresh install with that update.

Magnus von Bromsen says:


I’m afraid that I don’t have a solution for you. But I also have 10.6.2 – and I *think* that’s working all right (at least, the info.php seems right).

— magnus

@crucco – a quirk I noticed…

You say you have php.ini and PHP.DEFAULT.INI, but on two machines I have php.ini and PHP.INI.DEFAULT. See the difference? Maybe there is a conflict there.

Have you tried deleting php.ini, duplicating and then renaming your PHP.DEFAULT.INI to php.ini, and restarting? Try without the other ini file in there.

Again, this doesn’t seem like 10.6.2 issue, at least not to me (or MvB).

Jared Howard says:

I was going nuts trying to figure out why this wasn’t working for me. Everything looked like it worked correctly until I restarted Apache and my phpinfo page wouldn’t pull up. I noticed that I could have a blank php.ini and restart Apache and it would pull up just fine. It took me awhile but I noticed that by default short_open_tag=Off. Well out of habit I use <? instead of <?php. Once I turned short_open_tag=On, it all worked for me with mcrypt installed. Thanks.

crucco says:


excuse me if I’m wasn’t precise enough. The filenames are as you told: php.ini and php.ini.default. maybe it depends also on the newest xcode321_10m2003_developerdvd.dmg I used to install xcode-tools. The strange thing to me is that it was a clean install on a fresh formatted disk with snow leopard from Mac Box Set and the 10.6.2 Combo-Update. That was all I made: install, update, install xcode. made php.ini from php.ini.default changed only the one line with the ;date.timzone= to ‘date.timezone=Europe/Berlin’ started the Webservice with httpd.conf LoadModule php5 without #. PHP works when there’s no php.ini. The Timzone-error remains on phpMyAdmin. All the rest is fine….cloned the System with superduper to a firewire-disk tried to boot instead on MacBook Pro on an iMac. The problem persists.

crucco – I’m at a loss, particular since I don’t really know what effect date.timezone would have on mcrypt. The only thing I can suggest is cleaning out the source and starting over. Sorry.

crucco says:

did a clean reinstall on another harddisk with snow leopard created a php.ini from default, activated php in httpd.conf – same thing again.
are there any apple specialists around who can explain that to me? on the whole internet there’s no discussion of that phenomenon….

Travis says:

Thanks so much for the tutorial — worked like a charm!

crucco says:

found the error: I have tu use instead of the short form . Now the PHP-Info gives the right
output. If one uses the short form on mac you get a blank page with no error message. How dumb I was….

crucco – Glad you got it working. Jared Howard (above) had a similar problem. Not dumb…just technology!

Stephen says:

I get to the point where I ./configure php. But I end up with
Notice: Following unknown configure options were used:
Check ‘./configure –help’ for available options

when I do check for available options I don’t see an option like –with-php-config.
I noticed that Bryan had the same problem with mcrypt. Unfortunately he didn’t say
what he was doing wrong.
Any idea where to start looking is welcomed.

Stephen – Do you have the latest developer tools installed (in other words, does /Developer/SDKs/MacOSX10.6.sdk exist)?

Stephen says:

Yes, both ( OSX 10.6 and Xcode 3.2 ) from the SL DVD. One thing I forgot to mention was that I did a clean install of 10.6.
Not an update over my old 10.5. I noticed with other tools that they needed some tweaking to work again ( AVR compiler
tool chain needed other compiler settings ).

Stephen – Without a machine I can try doing a clean install on, all I can suggest is deleting all source, making sure the existing install of PHP is the same version as the source you downloaded, unwrapping everything and trying again.

Michael Kaiser says:

Hi Michael,
thanks a lot for your tutorial. I never would find this out by myself.
I have a little problem while installing the PHP extension from ext/mcrypt. The configure command starts, checks some things and then stops with the following error:

checking for MSSQL support via FreeTDS… yes, shared
configure: error: Cannot find FreeTDS in known installation directories

No makefile is generated.

Any suggestions…?
System: 10.6.2 Server (german)

Michael Kaiser says:

Problem solved. After downloading PHP 5.3.0 from Apples Open Source Server the installation worked without a problem.

Jesse says:

Hi Michael,

Your tutorial has helped me a lot.

While I can run through these steps on one machine what I really need is something I can plug into my software installation process (I develop some software that depends on the mcrypt PHP extension).

Is it enough, after building the PHP extension to just copy this into the extension folder and setup the php.ini settings appropriately or do I need to do some other steps to get libmcrypt installed up first?


Jesse – You could do that, assuming all the operating environments are the same. Unfortunately, the moment they differ or something gets upgraded, like PHP itself (which happens occasionally with OS X updates) you’re toast.

My suggestion would be to write a script (maybe use Perl) which would check PHP versions, check for libmcrypt existence, grab all the relevant source code, and does the compilation and various mods for you.

Jesse says:

Thank Michael.

Can I get away with just installing the extension “” or do I need to plug in all the other executables that are created and installed during the libmcrypt steps above as well.

In other words does stand by itself after all the steps above are done or does it in fact depend on the libmcrypt executables them selves also being loaded on the system.


It should stand alone (but that does assume the environments are identical).

Chris Stetson says:

Just as a note, you need to use Bash in order to get the commands to work correctly. I prefer tcsh (legacy reasons) and the environment variables don’t work. Once I switched to Bash, things went much more smoothly.

Chris says:

Thanks so much! 🙂 … it works great

very clearly, precise and easy to understand tutorial, thanks again for sharing this!

Kenny says:


Thanks a bunch for the tutorial! It’s definitely one of the better ones that I’ve seen. Unfortunately I’m still having issues getting the mcrypt extension working. I’ve gone through this tutorial 2 times already, each time wiping the source (in SourceCache). But PHP is still not recognizing mcrypt. Could the problem possibly be with my configuration of PHP?

Many thanks!

bveale says:

Super tutorial, thank you so much…

@Kenny – Shouldn’t be, but wondering…have you done your own PHP compilation?

@bveale – You’re welcome!

Kenny says:


No, I enabled the built in PHP via uncommenting line115 in the httpd.conf file.

Ok. I’m assuming PHP is running, and that the compiles worked without error. Dynamic loading enabled, and you have on a line under dynamic extensions?

Also, search for, and post where you found it. If you found it.

Kenny says:

My file is located in /usr/lib/php/extensions/no-debug-non-zts-20090626/

Kenny – it is in the right place for certain. Hope you can wait a few day to see if someone comes along and has the same problem plus the solution. The only thing I can think of is clear the browser cache, because right now it should be running. Sorry I can’t be of more help at the moment 🙁

Nick Merritt says:

This was just straight-up helpful and your assistance was very much appreciated. Thanks for putting me one step to closer to command-line fearlessness. and Happy holidays!

Paul says:

Hi, This worked fine for me until the rename php.ini.default to php.ini bit. If I do this and try and run phpmyadmin I get the following error
“#2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)” I can change back to php.ini.default and phpmyadmin works fine but phpinfo doesn’t show mcrypt anymore(it does if I use php.ini). Any idea’s?

Paul –

Do other PHP applications work when php.ini is in place? I’m not familiar with phpmyadmin settings, but it might be a simple matter of it looking for php.ini.default – can you change it to look for php.ini? Also might make sense to just copy the default file as php.ini, leaving the original file intact.

Paul says:

No, another php app also stopped working (couldn’t connect to mysql) I had tried having both the php.ini file and the php.ini.default in place but this made no difference. phpmyadmin doesn’t seem to have any setting as to looking for the php.ini file. Thanks for taking the time to reply. It’s not a big deal as it’s only a development machine, mcrypt is working fine on my webserver.

Dale says:

I need to get 10.6 PHP fixed and to understand the PHP plugin process. I can’t believe this is such a pain. In you instruction am I going to be replacing the stock PHP? or just using the source to do the builds? I might give this a try



“just using the source to do the builds”

Sebastian says:

You were so helpful to me! Thanks a lot!

Freedom OSS says:

Thanks mate! It works fine. I can use now my phpMyAdmin without giving me the nuisance error for mcrypt.

More power to you!!!

Roger Creagh says:

Another vote of thanks for some very clear and easy to follow instructions with just enough explanation to help one understand what is going on and needs to be done. Worked exactly as stated on the tin.
Many thanks.

ThinkMud says:

@Paul did you fix your #2002 error with mysql? I’m getting the same think:(

ThinkMud says:

@Paul actually I found a fix for the MySQL #2002 error in phpmyadmin, I had to change from using “localhost” to “” in this line:

$cfg[‘Servers’][$i][‘host’] = ‘localhost’;
$cfg[‘Servers’][$i][‘host’] = ‘’;

hope that helps.

Paul says:

Thanks ThinkMud that worked. Had to change my php apps from localhost to for them to work also.

ThinkMud says:

There has to be something we can set somewhere for MySQL to make localhost point to, you know? like the hosts file is already set up to do that, wonder why MySQL doesn’t do it? I’ll keep searching b/c I hate to have change all my config files to point to instead of locahost because all my live sites have localhost. I’ll dig around more tomorrow and figure it out:)

EpiDot says:

I am just one more who is very grateful for this information! Thanks a lot!!

[…] the following site which has instructions on plugging the mcrypt module into php on Snow Leopard: Plugging mcrypt into PHP, on Mac OS X Snow Leopard 10.6.1 which was a godsend. It worked out of the box for me. I believe it makes(compiles) the […]

Turborob says:

Just one more confirmation regarding Chris Stetson’s comment that some of the commands need to be done in Bash. Specifically, the configure of the PHP mcrypt failed on my system as unable to determine the version of libmcrypt. Once I did everything as sudo -s, it worked fine. Next problem I had was following some other instructions to place my php.ini file in /etc/apache2, but PHP was looking for it under /etc (logically where the default file is already located). Works great now and thanks for the tutorial!

Brent says:

@Michael Gracie – Thank you, thank you! Its been a long day and this finally was something that went right.

@ThinkMud and @Paul – I solved the error (the issue) with phpMyAdmin by changing “/var/mysql/mysql.sock” to “/tmp/mysql.sock” everywhere in the php.ini file and then restarted the web server. I’m not sure why that works.
I found it at:

You are definitely welcome Brent.

ThinkMud says:

@Brent Thanks dude! seems to work good now.

@Micheal Gracie – Thanks for the write up, this is awesome. I’m the type of guy that always has to have a local set up to match my live sites so I can fully test locally and not break the live sites. This has saved me lots of time. Thanks again!

Wanted to say thanks for writing this up, I had managed to perform this installation first, and then upgraded the GD package to include FreeType as documented here:

(Be sure to look for my comments that have fixes to some of the recompile process)

Was glad that the recompile of PHP for GD did not affect mcrpyt.


Mark says:

Micheal thanks much for writing this up. Saved me a bunch of time fishing for answers.

Laura Landy says:

Thanks for this info.

I’ve gotten this far:

Move back to /SourceCache, then down to php-5.3.0/ext/mcrypt – type…

/usr/bin/phpize (phpize should be in /usr/bin – if not go find it and change the command as appropriate)

Then configure as follows…

Confused. phpize is not a directory. Do I just go to /usr/bin and configure? {note: I already had PHP5 installed.]


Laura –

phpize is an executable – you are not going in there, you are just typing the command ‘/usr/bin/phpize’ to run it. If it’s not in /usr/bin/ you have to go find where it is, and run with it’s correct path.

Laura Landy says:

Michael, thanks for the info, and I still don’t get it. Because I already had PHP installed, I didn’t create the SourceCache dir.
I am typing usr/bin/phpize at the prompt
but get the response: usr/bin/phpize: No such file or directory.
Yet when I list the files in usr/bin the phpize is there:

laura-landys-macbook-pro:/ lauralandy-PB4$ cd /usr/local/php5
laura-landys-macbook-pro:php5 lauralandy-PB4$ ls -l
total 89336
drwxr-xr-x 9 root wheel 306 Mar 26 2009 bin
-rw-r–r– 1 root wheel 440 Mar 26 2009 entropy-php.conf
drwxr-xr-x 7 root wheel 238 Jan 24 18:29 etc
drwxr-xr-x 3 root wheel 102 Mar 26 2009 include
drwxr-xr-x 62 root wheel 2108 Jan 24 18:29 lib
-rwxr-xr-x 1 root wheel 45732808 Mar 26 2009
drwxr-xr-x 14 root wheel 476 Jan 24 18:29 php.d
drwxr-xr-x 4 root wheel 136 Jan 24 18:29 share

laura-landys-macbook-pro:php5 lauralandy-PB4$ cd bin
laura-landys-macbook-pro:bin lauralandy-PB4$ ls -l
total 87848
-rw-r–r– 1 root wheel 1973 Mar 26 2009
-rwxr-xr-x 1 root wheel 824 Mar 26 2009 pear
-rwxr-xr-x 1 root wheel 845 Mar 26 2009 peardev
-rwxr-xr-x 1 root wheel 761 Mar 26 2009 pecl
-rwxr-xr-x 1 root wheel 44949320 Mar 26 2009 php
-rwxr-xr-x 1 root wheel 3726 Mar 26 2009 php-config
-rwxr-xr-x 1 root wheel 4198 Mar 26 2009 phpize
laura-landys-macbook-pro:bin lauralandy-PB4$

I am very new to using terminal so I am probably missing something very basic.

I appreciate your help, thanks!


Laura –

Because I already had PHP installed, I didn’t create the SourceCache dir.

You must grab the PHP source code for your version of PHP, and follow the directions exactly as prescribed above. Most if not all users of these instructions already have PHP installed – you need that source code to create the mcrypt plugin.

Again, there are no shortcuts – follow the instructions to the letter. UPDATE: you can’t type “usr/bin/phpize” – you must type “/usr/bin/phpize”

Laura Landy says:

Thanks, Michael. After many hours of fighting, I just installed MAMP, so I guess I took a short cut ;}

Frank Indelicato says:

Thank you Michael, your advice worked without a flaw…good luck merging the fly-fishing….

Maryann says:

I did the install and it all went well, but when I restart apache, mcrypt does not show in the phpinfo page – is the only file snow leopard reads php.ini? It seems like it’s not picking up any changes in the php.ini file.

@Maryann – I’m assuming “all went well” means compile completed without errors. Check to make sure that is in /usr/lib/php/extensions/no-debug-non-zts-20090626/, that it is properly linked per the instructions, and that dynamic linking is enabled.

Maryann says:

yes, that’s what I meant – no errors, I ran it again to be sure it went without error. mycript is the right place, I setup the linking – how do I check that dynamic linking is enabled? It just seems like apache is NOT reading the php.ini file – does snow leopard read an alternate php.ini file somewhere other than /etc/php.ini? Thanks for responding, I really appreciate it!!

From above –

Ensure that enable_dl = On but do not remove the ; from in front of ;extension_dir = “./”

Apache shouldn’t be looking at anything else (assuming PHP is running, and you are using the out-of-box version), but that’s up to httpd.conf. I’d starting looking through phpinfo() results next.

This is probably going to wind up being a minuscule detail, which is always the worst part of debugging.

dd says:

Big thanx man !!. All worked well. Thx again.

erinol says:

@Maryann – I also had a problem with mcrypt not working, but compiling and installing fine. It turned out that it wasn’t reading my php.ini file. run phpinfo and check the “Loaded Configuration File” Value (it said not read for me). Once I fixed that, everything was fine.

Thanks Mike!

Maryann says:

I got it all working, worked great! (finally!)

Dani says:

I am just learning all this please explain this part

Move back to /SourceCache, then down to php-5.3.0/ext/mcrypt – type

/usr/bin/phpize (phpize should be in /usr/bin if not go find it and change the command as appropriate)

Joel says:

Hey Michael – appreciate the guide. Have done this on a couple of my machines to get up and going and had great success. Ran into an issue on my last machine however. When I run /usr/bin/phpize, I get the error: “Cannot find config.m4. Make sure that you run ‘/usr/bin/phpize’ in the top level source directory of the module” I’ve looked online but not had any luck tracking down how to fix this. Any ideas?

John says:

I ran into trouble when executing “make -j6” in the libmcrypt directory. I get the error:

ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
lipo: can’t open input file: /var/folders/fR/fRJnS6VWGW0QaiJPjG-P4k+++TI/-Tmp-//cc6Jdq6z.out (No such file or directory)

John says:

Mea culpa. I had the production version of libmcrypt. Once I trashed that and downloaded version 2.5.8, life became happy.

I thought I was being cautious when I used production, but I was just being wrong.

albert says:

Big thanks to michael mcrypt works now after long search in internet. Great work and easy to install.

Hans says:

@Joel: I ran into the same problem and found a solution here:

Go into cd /SourceCache/php-5.3.0/ext/mcrypt before you run phpize.


Mario says:

Wish I had an idea of all I’ve just done 🙂
Thank you.

Just a note on the download of the libmcrypt, like somebody else already said, the link provided takes to a file that says it has both files (mcrypt and libmcrypt) together, but I couldn’t get the libmcrypt alone… so I found it somewhere else ( to be exact) and worked with that file.

Maybe the mcrypt file provided worked, but since you made a point out of getting libmcrypt alone..

Again, thank you!

Svish says:

Thanks! Worked flawlessly on first try =)

Nancy says:

Fantastic! Worked like a charm – even for a novise like me!

Rémi says:

nice tutorial. Thank you !

Thanks Michael. This worked a treat for me – I already had XCode installed so just needed the two other downloads. I lost phpMyAdmin after upgrading to 64-bit MySQL in Snow Leopard and this fixed the problem.

PS One more thing. For less Unix-familiar users, you can use the following two commands for path etc on most systems:

1. “which xxxx” – where xxxxx=name of other command. It will come back with the location of the executable for that command. For example, typing “which phpize” will usually give you “/usr/bin/phpize” back.

2. “pwd” – this tells you the path to the directory you are currently in.

Sebastian says:

Greets from Berlin, Germany.

Thanks for the great tutorial. In the first try forgot the step where you call /usr/bin/phpize and got the same errors as Bryan, but then it worked out great.

Michael says:

Worked perfectly. Cheers.

Ess says:


Thank you very much.

Reda says:

Thanxs ! This tutorial is awesome !

k00k says:

Oh Man, this worked wonders. Thanks a billion! I was struggling with Snow Leopard’s lack of mcrypt.

Ross says:

Thank you sir. Excellent work.

Ward says:

Thanks for the tutorial, seems to have helped alot of people. Not working for me though. I’m on a 13″ macbook i bought in February 2010. Turned on web sharing. Enabled php just fine. Installed mySql and phpMyAdmin just fine. However when trying to login to phpMyAdmin i get the mcrypt not installed error. 🙂 So on I went, three tutorials later I am at your page and this is looking good. Followed the instructions. Get to this point:

MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ LDFLAGS=’-O3 -arch i386 -arch x86_64′ CXXFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ ./configure –with-php-config=/Developer/SDKs/MacOSX10.6.sdk/usr/bin/php-config

and I get the

configure: error: Sorry, I was not able to diagnose which libmcrypt version you have installed.

Someone mentioned running locate mcrypt? I get this:

bash-3.2# locate mcrypt

Should i just start over? Find some tutorials on uninstalling php? Mysql?


Thanks for any help

Yaniv says:

Michael, Bryan,

I’m puzzled. In the source code of PHP 5.3.0 (and .1 and .2) there’s no –with-php-config option to the ./configure script. When I run it, I get the warning message that Bryan mentioned in his comment of October 21. The referenced file (in /Developer/…) does indeed exist.

G.Dubya says:

Brilliant! Worked exactly as stated with 10.6.3, MySQL 5.1.46, and PHP 5.3.1.

So grateful that you published this!

Chris says:

Hey Michael! Thanks very much for this tutorial; works great!!

Jonathan says:

Fantastic guide, Michael. This was quick and painless on OS X 10.6.2/PHP 5.3.0

joan says:

Fantastic tutorial, it also works wiht the 5.3.1 php

thank you so much…

[…] about was that libmcrypt was missing. After a few web searches, found this helpful info from Michael Gracie. First, you are going to need a few […]

Papang says:

Thank you very much for this tutorial. It works very well.
Merci beaucoup pour ce tutorial. Ca marche à merveille.

Mat says:

Hi, sorry – when you say create a new directory at root is that in the library / webserver / documents directory or in the mac system root – if so do I have to do anything to reveal the root dir of the mac os?

@Mat – System root, which can be at your admin user. So, at /Macintosh_HD will do.

A hundred and twelve thankyou’s!

I found your awesome tutorial after a struggling with a different one for two hours.

Yours: 5 minutes and done!

Mat says:

Sorry for my naivety …where do I find the directory /etc

Mat says:

Does this /etc folder exist by default, or is it added as a result of the process as above?

Mat says:

OK the etc folder is within the “private” folder (which as far as I am aware isn’t visible under the file system as standard, I found it using the web browser and typing /etc/ into the address bar) under root as you said. I feel like I am being taught a lesson here (for my good perhaps). None the less, I did persevere and I have got mcrypt working – so many thanks. …if I can do it – anyone can!

Hormoz says:

i encountered a problem. after runnig the first command when i entered “make -j6” it said : “make: *** No targets specified and no makefile found. Stop.”
now i know i should specify a file or something, but what should i specify ?

The instructions are intended to work exactly as stated. Could be wrong directory, or wrong source code download.

Hormoz says:

yep, it was a minor mistake from my side. tnx for this guide.

Luis says:

It worked!
It’s easy, as you mentioned.
So now it’s loaded as a dynamic module. Never tried that, because I am always working in Linux, compiled, and so on.
Now trying to recreate a working machine at home.
To access root directory, in case somebody has problems locating it, in my machine, a normal MBP, type in terminal:
sudo cd /private/var/root
and then the root password.

Thanks a lot.

Thomas says:

Thanks for that – very useful.

I found that if you have white space in your ‘cache’ folder name, the process doesn’t run properly. As ever, always follow the instructions!

kiran says:

i am getting the following error after running ‘make -j6′ while installing libmcrypt :

make all-recursive
Making all in modules
make[2]: *** No rule to make target `all’. Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

please help..

Kiran – Could be wrong source, wrong directory…even a typing error.

Best suggestion…start over.

kiran says:

i dont know how, i started all over again with the same files and everything works just fine… thanks a lot

stooky says:

hi michael

some questions please:

if I do understand you right, this method installs libmcrypt and injects it to the existing installed php?!

a) will it work on a preinstalled php 5.3.2 as well? have a new mac and php 5.3.2 is installed and running.
b) create directory at root you mean / not /private/var/root
c) after all the process if mcrypt is propperly showing up in phpinfo, the source cache can be deleted? (if we need this just for injection into existing php installation it should be obsolete after success).

thc and rgds,

a) it should
b) yep, root, like /Macintosh HD
c) yes

stooky says:

cheers michael

worked smothly on
macbook with php 5.3.1
macmini with php 5.3.2


Aziwaan says:

Hi Michael,

I have followed your instructions to the T, everything through terminal worked with no errors however when I run i cant see mcrypt. Ive restarted websharing but still no joy.

Any suggestions??

cheers in advance.


Could be php.ini, which I’d double check first. With no way to replicate/debug I’d delete all the files and start from scratch.

Aziwaan says:

Scratch that last one, I kooked it, had commented out in php.ini : (

Thanks again.

David says:

Thanks for this, it finally got mcrypt working for me after a few attempts following other guides. Just something I came across when I did it and in relation to Brent’s comment on January 18th (I wanted to make sure nobody had posted this fix already), if you don’t already have a php.ini and you copy the php.ini.default to create one, there is a bug in OS X in that the php.ini.default file has the location of your mysql socket as being at /var/mysql/mysql.sock. However, if you have installed mysql from scratch, the default location for it (and maybe this is just a 10.6 thing, it may be somewhere different on Leopard and earlier) is at /tmp/mysql.sock. That’s why Brent’s fix worked. A slightly more reliable way to fix the issue is simply to comment out the line that declares the mysql.sock location and your system will search for and find it.

In short, the issue Brent had is simply bad configuration in Snow Leopard…

[…] so you’re in reasonably safe hands).  After following the tutorial on installing mcrypt from here I started getting an error connecting to the mysql server I have running on my development system. […]

Doctor Sushi says:

Just used your instructions on OS X Server 10.6.3, with the PHP 5.3.1 source. Worked perfectly.
Thanks for the excellent walk-through, you just saved me countless hours.

NightFury says:

Kudos! – This worked wonderfully!

m7o says:

I would also like to say Thanks A Lot!

For all who are not so familar with the terminal (like me): Make sure you are working from the “bash” shell. You can set this in Terminal -> Preferences. In my case the shell was tcsh, probably because I use the same User since the very first days of OS X. And in the tcsh shell the commands won’t work (different syntax).

m7o says:

I just saw that somebody already mentioned the tcsh thing… sorry

nottinhill says:

The trick by david with the mysql socket locatioin did it for me. Excellent! I wrapped this into my own tutorial about how to install magento on Unix:

flexliv says:

Worked like magic. I used this for phpMyAdmin after installing mysql.
Great tutorial.

[…] everything that I need except mcrypt.  Luckily Michael Gracie has provided a walk-through for installing mcrypt on Snow Leopard which involves re-compiling some things, but isn’t as tough as it first […]

Michael Johnston says:

Thank you!!!

Chris says:

Okay, so i’ve been struggling with this issue for some time now and have now come across your page: I have the libmcrypt-2.5.8, also the new PHP 5.3.3. However when going through the first step(typing in “MACOSX_DEPLOYMENT_TARGET=10.6…”) i’m running into what seems to be a trivial but yet bothersome error. It returns the error:

“checking build system type… /bin/sh: ./config.guess: No such file or directory
configure: error: cannot guess build type; you must specify one”

I have no idea why it couldn’t use / find the guess.config. So far i have been really stuck at this point….I have Apache 64-bit, MySQL-64-bit, and currently php5.3.1 64-bit installed(without mcrypt), but would like to switch to newer version(5.3.3) also(which means uninstallation of current and probably build new one). This one error is stopping the mcrypt installation which i need for phpMyAdmin. Any suggestions about this issue?

Also, i have tried a MacPorts install for mcrypt and it seems to have a compiled 64-bit unix executable version of mcrypt that was generated, however that’s not being recognized by the php and i’m not sure how i might just use the unix executable file from the MacPorts build and add it as a php module( if that is even possible).

Chris –

It seems you may be using the wrong source – if you have 5.3.1 installed, you must use the 5.3.1 source (not 5.3.3). That’s all I can guess, as you’ve got so many moving parts engaged.

Chris says:

Hi Michael…

It turns out it was obviously a silly error on my part. What i meant to say was that i was in the libmcrypt-2.5.8 and using the corresponding flag options the (MACOSX_DEPLOYMENT_TARGET=10.6…) part, when it was returning the error i stated. So i just skipped that module and tried installing others which seemed to work fine, because once i got the xdebug module working, i tried at the libmcrypt again, but this time re-downloading and unpacking it. It turns out that the original libmcrypt downloaded with an error, didn’t unstuff correctly and therefore the associated folders that were needed weren’t there, which explains the error…

Also i notice with some websites when setting the flag options for the configure(libmcrypt-2.5.8) they have:
1 ) ./configure –disable-posix-threads –enable-static

and using your options we have the:
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ LDFLAGS=’-O3 -arch i386 -arch x86_64′ CXXFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ ./configure –with-php-config=/Developer/SDKs/MacOSX10.6.sdk/usr/bin/php-config

Is there a notable difference between the two options or are they relatively going to function the same way?

christine says:

I’ve got xcode and have created a sourcecache folder through xcode. But, it’s a freaking book. I’m only an artist that wants a dynamic website to show my work. I don’t know where to begin. I have the folder where do I put the libcrypt code and php code in this xcode?

Christine – The instructions are meant to be followed verbatim – all the commands are done from terminal. If you are not comfortable there, and/or don’t have a general understanding of software compilation, it might make sense to get someone to do this for you.

christine says:

I get the following error message when I type the first part into my imac terminal:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ L’ at line 1

Sounds like you are logged into MySQL. I guess the question is “why”?

Schorsese says:

Great! Thank you!

Adrian says:

I seem to be having issues while entering the ‘MACOSX_DEPLOYMENT………../configure –disable-dependency-tracking” in the libmcrypt directory….

I get the following:
checking build system type… i686-apple-darwin10.4.0
checking host system type… i686-apple-darwin10.4.0
checking target system type… i686-apple-darwin10.4.0
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for gawk… no
checking for mawk… no
checking for nawk… no
checking for awk… awk
checking whether make sets $(MAKE)… no
checking whether to enable maintainer-specific portions of Makefiles… no
checking whether make sets $(MAKE)… (cached) no
checking for g++… no
checking for c++… no
checking for gpp… no
checking for aCC… no
checking for CC… no
checking for cxx… no
checking for cc++… no
checking for cl… no
checking for FCC… no
checking for KCC… no
checking for RCC… no
checking for xlC_r… no
checking for xlC… no
checking for C++ compiler default output file name… configure: error: C++ compiler cannot create executables
See `config.log’ for more details.

then ‘make -j6’ doesn’t work….

Could you please help? All I’m trying to achieve is to run phpmyadmin on my local mac web server.

Thanks in advance.

Adrian – looks like you don’t have the developer tools installed.

christine says:

When I enter this into terminal I get:

MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ LDFLAGS=’-O3 -arch i386 -arch x86_64′ CXXFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ ./configure –disable-dependency-tracking
-bash: ./configure: No such file or directory
host:mysql me$ -j6
-bash: -j6: command not found
host:mysql me$ sudo make install
make: *** No rule to make target `install’. Stop.
host:mysql me$

Christine – Either..

1) You don’t have the developer tools installed;
2) You are not in the right directory when you enter the command;
3) You are somehow logged into mysql; and/or
4) There is a typing error someplace.

Best I can offer is to try starting from scratch, following the instructions exactly like they are laid out, and copying the command into the terminal window.

christine says:


1. I’ve installed xcode, libmcrypt and php as instructed
2. You mentioned previously putting that code in terminal. So that is where I’ve been cutting and pasting from this page that code into my computers terminal. Unless you mean in the xcode field.
3. I’ve tried coding w/ mysql on and off and get error messages. Of course I’ve been coding into my computers terminal.
4. I’ve been cutting and pasting from this page. If there is an error message it’s from your page.

I am sorry you are having trouble, but enough people have stopped by here, successfully completed the task, and simply dropped a “thanks” that it’s pretty clear it isn’t an error in the commands displayed above.

I just reviewed all your comments, and the best I can suggest is either start over from scratch, or find someone to help you that is really comfortable at the UNIX command line.

Kennie29A says:

Thanks so much!!

Lennart says:

Thanks, worked like a charm!

Geoff says:

Worked perfectly, just like everyone else says. Thanks a ton for this, Michael! For what it’s worth, I did it just a bit differently; I put my sources in

~/src/libmcrypt-2.5.8 and

All the same commands worked exactly as above.

How on earth would you know how to do this… without this post… is beyond me!

I think Jim’s original 10-29-2009 question is perhaps better asked: Can the same exact steps (terminal commands) be used to compile other libraries? I am guessing that /usr/bin/phpize, make -j6, and sudo make install install, would be logical, but how do you learn to create a configure command?

Geoff –

Thanks, and glad it worked. Obviously, I had help (as noted at the top), but it was a lot of trial and error.

As for understanding the configure command, well the introduction of 64-bit has complicated the matter, so the best bet is to research for the best fit for a particular selection of source code.

For example, I’m working with GPG now, and the source only works in 32-bit mode. Hence, compile command turns out…

./configure CC=”gcc -arch i386″

Again, it isn’t my brainchild, but researching what needs to be done to utilize the tools others have so graciously provided us.



[…] You are going to need the PHP extensions mcrypt and curl. Curl was simply uncommenting the line extension=php_curl.dll in the php.ini file. Mcrypt was a bit more complicated, and I used this article. […]

Rollaway says:

Many thanks for this! Worked like a charm.

flamencoman says:

Many Many Many thanks!!!

Blair says:

Michael, thanks for providing these instructions.

I was inclined to try to compile php again from scratch to get mcrypt installed – that is until I realized how much work would be involved (especially since I’m pretty new to using the shell).

It may have already been mentioned above (there were so many comments I couldn’t check) but the instructions didn’t work for me first time and the reason, I think, was that I tried to install using the wrong version of php (I’m using Snow Leopard 10.6.4 which has php 5.3.2 built in). I went back and re-tried using php-5.3.2 and this worked.

If I’m correct in this, it may be helpful including a note in your “First, you are going to need a few things…” section to encourage noobs like me to check phpinfo() to see what version of php they have, and then substitute that into the download link you provided.

Anyway, thanks a million!

Done. Thanks!

J'aime says:

I had an additional issue where my phpinfo wasn’t working. It was displaying the text of the phpinfo file. It’s because snow leopard doesn’t *enable* php by default, though it has it.

Follow these instructions to fix:

Blair says:

There’s no way I could have done this without your instructions so I’m glad to be able to contribute in any tiny way possible!

Out of interest, is there any resource you can direct me to that will help understand what is happening between “MACOSX_DEPLOYMENT_TARGET=10.6” and “./configure –disable-dependency-tracking” (i.e. the first two lines of each set of instructions? I have researched the “configure” and “make” commands, so I can follow that bit OK, but the first part is completely beyond me! I always like to try to understand every command I type in for two reasons:

1) so I can be sure I won’t do any damage to any important files through incorrect command entry; and
2) so that I can begin to work out for myself what to do the next time I need to run the command.

Admittedly this desire to understand everything has meant that for me to enable the OS X built-in php and install MySQL (something that various people online describe as a simple process) has taken MONTHS, but I like to think it is much better practice in the long term…

Enough waffle – thanks again!

Blair says:

I’ve just spotted on the Leopard version of this page that you responded to Chuck explaining that you got some of this code from others, so please ignore my previous request for further instruction.

Vincent says:

Excellent guide, worked like a charm.

Thanks a million!

Bret Abel says:

Excellent! Thanks for the straightforward guide, it worked flawlessly… with one caveat.

When I began, I ran into the same problem as Adrian and Magnus: the first “MACOSX_DEPLOYMENT_TARGET=10.6 …” command was failing, preventing me from going further. However, I was sure I had Xcode installed; I use it on a daily basis for iOS projects and have never had any issues. At wit’s end, I decided to reinstall Xcode from my system disk.

In the Xcode installer, I noticed a checkbox for UNIX Dev Support, which is checked by default. Its description indicates that it provides “Optional content to allow command-line development from the boot volume.” A-ha! When I had originally installed Xcode a year ago, I decided not to install this feature, figuring that I’d save myself half a gig by not including something I’d never use. Of course, command-line development is precisely what we’re doing here, so the UNIX Dev Support is a prerequisite.

For others who find themselves in the same boat, there’s no need to reinstall Xcode from scratch. Just launch the Xcode installer and install UNIX Dev Support on top of your existing installation.

mikev says:

First thanks for this page. I’ve been fighting with php, mysql, mcrypt, snow leopard (10.6.4 64bit) off and on for the past week. You brought me to a happy place :o). It’s all working.

A couple of quick notes: the first ./configure wouldn’t run until I dropped the -arch i386 but kept the -arch x86_64; the second ./configure needed both i386 and x86_64.

And second, the last 6 hours of head-banging[1] was due to php.ini not being read…. because it was in /etc and not where php was looking for it: /usr/local/lib. erinol’s comment of Feb 21 above clued me in.

phpinfo() was not only not displaying mcrypt as loaded, it kept refusing to recognize timezone. …So, you might want to put a note up top here to keep the idiots (like me) from bothering you. If everything seems to have worked and mcrypt still isn’t loading, run phpinfo and check the values in “Configuration File (php.ini) Path” and “Loaded Configuration File”.

Thanks again.

Ian M says:

Chiming in to say thank you Michael for this excellent post, and thank you Bret for pointing out that all Xcode installations are not equal! I too was missing the Unix Dev Tools so I’m very glad I took the time to read all the comments!

Ian –

Glad it worked out for you. I’m adding a note to the post with respect to your note.


Once I took the time to download the latest XCode package, this worked flawlessly. Thanks Michael for posting this info. You saved me countless hours!

Eric says:

You are a god among men. Thank you so much for this guide.

sacha says:

Mike you rock! Thank you!

[…] connect to my mysql installation but I get a "Cannot load mcrypt extension. I did this tutorial – – to get mcrypt installed and phpinfo() shows mcrypt is installed as per the screenshot at the […]

[…] his Step 2, grab the PHP source that matches “$ php –version” on your system): . The following files will be […]

jamroks says:

So So Cool merci beaucoup Monsieur Gracie

works like a charm, thanks!

fernando says:

great, thank so much the best tutorial to get mcrypt and configure correctly phpmyadmin…. any doubts after this…

Laurie says:


Many thanks for this guide…

I can confirm that using mcrypt 2.5.8 and PHP Version 5.3.3 on Mac OS X 10.6.5, coupled with xcode 3.2.4, the install was undertaken exactly as documented and was successful.

I’m not sure if this helped or not but I ran all commands as the root – excluding the “sudo” aspect where relevant.

Thank you

Robert says:

Hi Michael,

Thanks for this great and clear manual. I followed your instructions on a brand new snow leopard server and it worked without any hassle. People whom may run into problems: please read and follow the instructions!

Thanks again Michael!!!

Much appreciated Robert. The initial sources also deserve thanks, as do numerous contributors who have discovered various quirks along the way.

Boris Chervenkov says:

Brilliant! :o) Thanks a million !

Took literally 10 minutes from start to finish – including downloading, configuring, building and installing. Thank you very much!

Anthony says:

I hate to bring this up but I have downloaded the source from the PHP archives and Apples Source Archives for version 5.3.3 (the one the my current snow leopard is running) and I have no configure files? I have downloaded the source twice from each and so I have configured and installed libmcrypt-2.5.8 but when I try to do the same for mcrypt under libm…/ext/mcrypt/ I get the error.

-bash: ./configure: No such file or directory

Now, I am neither new to Unix or Mac and I know the tools are installed because it wouldn’t have worked for me before. As far as I can tell, I just don’t have the configure file in my download. There is one in the main php directory but no configure files in the ext/ or mcrypt/ directories. Does this confuse anyone else?

Anthony says:

Ok, that was my fault, next time I need to slow down when reading. 😛 My issue was I didn’t run phpize. As I read the instructions, I made sure it was there but me flying all over the place didn’t run it. Great tutorial by the way, for those who slow down to read it.

Armando Dinarcisco says:

I like when people gives simple instruction that works. You are a genius Michael. One question:
May i delete the tmp folder called SourceCache ?

You’re welcome! And thanks (though not likely)! Finally, yes.

Graham says:

This guide worked absolutely perfectly for me! Thanks for the help!

James says:

The guide worked great, even in the updated PHP 5.3.3 (just downloaded the newer source as suggested).


It works great on OSX 10.6.6.


Mac escort says:

From France : Bravo !

This guide was very useful and the best on the net.

I only had some permissions issues, resolved by chmod. Maybe precise it.

Very good work.

Mac escort says:

I have forgotten to mention my config : PHP 5.3.3, Apache 2.2.15, XCode 4 GM (yes !), PHPMyAdmin, MySQL 5.5.8

Re-BRAVO !!!!

Mac escort says:

And of course, sorry : MacOS 10.6.6

Re-Re-BRAVO !!!

Wilson says:

Thank you!!!

Gripskrauler says:

This is an excellent guide!
it is still needed for Mac OS X 10.6.6 and it still works without any error 17 months after its first release!

Michael, thank you very much

PhilG says:

Just used this to install mcrypt on a default install of 5.3.3.

I downloaded and used php 5.3.5 but everything worked out okay anyways.

Jonathan says:

Hi Michael, yes thank you for the guide.

Quick question though however, is I am having an issue initially getting it started I am new to using PHP. I have all the parts installed when I try to run the first Mac OSX Deployment Target you run that in Terminal do you not?

I’m just trying to figure out how to do this and been at it for about 4 hours and decided to ask exactly what I need to do. I have SourceCache File setup in my HDD Root. So what do I need to do next. Thanks for the help.


Yep. All the commands are run from Terminal.

Jonathan says:

Thank you for the answer to the previous question.

I still have the issue of it say ./config no such file.

I am trying to get this to work on Mac Snow Leopard Server was wondering if there is possible issue with the issue of how it is set up in Snow Leopard Server.

Also when you say move since I’m new to unix, does that mean just put the location of libmcrypt into the Terminal command and then follow up with the first Mac OSX Deployment Target Command?

I am running this in root command mode in the root user. Any help would be appreciated

Thank you.

Don’t have the server, so I can’t replicate what you are doing. But, “move” means change directory. If you are getting file-not-found you probably aren’t in the right directory – use cd /whatever to jump between directories.

And yes, root is fine.

Jonathan says:

Hi Michael,

Thank you so much for all the help, I found what the issue was and the information you gave, and it works perfectly without any issues.

Thank you again.

Have a great day.


Thanks for this great tutorial, it works perfectly with my setup which is..:

PHP 5.3.3 (But I used 5.3.5 source)
OSX 10.6.6
Thanks again!

krifur says:

great Tuts, don’t put coma before “” like all the others extensions, I’ve done this mistake, lost a few time…


Magnus von Bromsen says:

Many thanks, again, Michael 🙂

Just did the “dance” on a new Mac mini server with 10.6.6 (only changed to PHP 5.3.3). Worked great!

— magnus

[…] dealing with configuring, compiling and installing the items from source were adapted from this post. GA_googleAddAttr(“AdOpt”, “1”); GA_googleAddAttr(“Origin”, “other”); […]

This worked perfectly and took me only a few minutes. Many thanks!

[…] bem complexa. Esclareço que o artigo original não é de minha autoria, sendo extraído do blog do Michael Gracie, e consequentemente, adaptado para atender a minha necessidade. A versão do Mac OS Snow Leopard […]

[…] First mcrypt on Leopard, and now we ready for the winter cat. Additionally, special thanks goes out in advance to commenter Yvan Barthelemy (a.k.a. ybart) for. mac – Google Blog Search […]

kudos….worked perfect the first time

Just wanted to let you know it worked fine with php-5.3.6 source and xCode 4
Thanks for taking the time to post this.

Jon Pon says:

No problems! Not sure what I just did…but it got mcrypt working! So…thanks 😉

Fantastic! Works a treat 🙂 Thank you so much for posting this.
iMac Intel Core 2 Duo
OS X 10.6.4
PHP 5.3.1 (recompiled for Freetype)

Marabiloso says:

Perfect, very straightforward, got it work perfectly with php-5.3.3 supplied with latest X.6, brilliant!

JB says:

You need to write one of these for freetype and whatnot to get things like imagettfbbox and image generation working too. I’m working on freetype right now basically using these instructions.

Adilson says:

Congrats!! Works like a charm!!

I am almost gave up, but then found this site.



Rainer says:

Thanks, worked like a charm on php 5.3.4 SN 10.6.7! You saved me a lot of time and headaches, thank you again.

Romain says:

Very easy with your explanations ! Thanks a lot !

Toan Dang says:

I know this is a repeat but still want to say thank you very much for the great instruction.

Magic – works a treat . Xcode can also be found on Snow Leopard CD for those without an Apple developer account.

Correct. And I’ll add that you can pick up XCode 4 tools via the Mac App Store for just $5.

Gihad says:

Thanks a lot. You saved me a lot of time 🙂

Irdial says:

Flawless, crystal clear instructinos (yes, ‘instructinos’) thanks for the help.

brtdv says:

It does not work for me. I have OS X 10.6.7 and XCode 3.2.3 installed. I should mention that I’m on a new MBP with a Intel Core i7 CPU and 8GB RAM… Maybe that is the issue?

bash-3.2# MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ LDFLAGS=’-O3 -arch i386 -arch x86_64′ CXXFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ ./configure –disable-dependency-tracking
checking build system type… i686-apple-darwin10.7.4
checking host system type… i686-apple-darwin10.7.4
checking target system type… i686-apple-darwin10.7.4
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for gawk… no
checking for mawk… no
checking for nawk… no
checking for awk… awk
checking whether make sets $(MAKE)… no
checking whether to enable maintainer-specific portions of Makefiles… no
checking whether make sets $(MAKE)… (cached) no
checking for g++… no
checking for c++… no
checking for gpp… no
checking for aCC… no
checking for CC… no
checking for cxx… no
checking for cc++… no
checking for cl… no
checking for FCC… no
checking for KCC… no
checking for RCC… no
checking for xlC_r… no
checking for xlC… no
checking for C++ compiler default output file name… configure: error: C++ compiler cannot create executables
See `config.log’ for more details.


brtdv says:

Okay, I seem to have fixed the issue.

My current OS X installation was restored from a Time Machine backup, and it seems that some items (such as my PATH variable etc…) have not been restored from the backup. I reinstalled XCode 3.2 and now everything works fine!

[…] o phpMyAdmin. Esclareço que o artigo original não é de minha autoria, sendo extraído do blog do Michael Gracie, e consequentemente, adaptado para atender a minha necessidade. A versão do Mac OS Snow Leopard […]

Michael C. says:

Can someone set up a repository or something so we can post our files there? It’d be great to be able to simply grab the object file from somewhere and just plug it into the right directory and voila. We should have been doing this all along. Have a separate for each version* of OS X from Leopard onward.

*Where ‘version’ means only the versions where PHP (cli) or mod_php changed.

Michael C. says:

Okay, I guess I’m the only unlucky one here. I followed the instructions and I still don’t have mcrypt support via httpd. Both `php -m | grep mcrypt` and `php -i` show that it’s indeed loaded via the command-line PHP, and `php –rf mcrypt_module_open` shows that it’s recognized and working; however, mcrypt doesn’t show up in the module list when viewing a web page containing a call to phpinfo(). I’m on OS X 10.6.7 and am using the built-in Apache httpd. I added the correct “extension=…” line inside of /etc/php.ini and restarted the webserver. Again, the command-line PHP sees it, but httpd does not. Putting httpd into debug mode (LogLevel debug) shows nothing erroneous or telling. This is rather insulting because I have 10+ years of thorough experience in UNIX/Linux system administration, and yet even non-experienced users have gotten this to work. According to `file` and `otool`, I can see that is compiled for the right architectures and has been linked properly, so that’s not the problem. Does anyone have any clue what the issue could be? Is it possible that mcrypt support simply isn’t doable in 10.6.7?

Michael C. says:

FOLLOW-UP: Okay, I got it working. It seems as though you cannot, at least with OS X 10.6.7, use `apachectl` AND System Preferences’ “Sharing” control panel to control httpd. Use one or the other, but don’t alternate between both. What had happened was that I was previously using `apachectl`, but then used the control-panel version to restart httpd after installing mcrypt. The result was that two instances of httpd were loaded; the one that was being used to output phpinfo() was the old one that hadn’t yet loaded the mcrypt extension. The old/stale one was using the tcp46 interface; the new one used the tcp4 interface, thus getting around the fact that no two processes can bind to the same TCP port on the same interface. Quite a tricky little bugger to debug. I had to invoke `killall httpd` first, and then use only the control-panel invoker to start httpd. As an aside, I also noticed what appears to be a strange bug: when you use apachectl, the output of `ps aux | grep httpd` shows the following intermittent and random entries: “/usr/sbin/httpd –help”. So apachectl somehow triggers the httpd executable to get into a weird state in which its command-line help switch gets issued, even though its a background process. Not going to debug any further, since I’ve wasted enough time already, but in case anyone else runs into this, here it is in all its verbose glory.

gibbitz says:

Michael C.
This is my 3rd day of trying to get this working and your tip got me over the last hump. Thanks for posting it here!

Bloody Butcher says:

These steps worked like a charm for OS 10.6.7, PHP 5.3.8 and Xcode 3.2.6. Many thanks, Michael.

For those of us who attempted to issue the shell commands under the tcsh shell and were left scratching their heads until reading through the comments, could you add a huge announcement that the Terminal steps need to be done using the bash shell?

Again, many thanks Michael for a fantastic tutorial on making mcrypt available on my Mac.

I’ll note here that I recently pulled off this operation on an i7 2.3 with 10.6.7, using Xcode 4.0.2 (4.0 command line compilation tools didn’t seem to be working properly).

Thanks, worked great with Mac Pro 2*2 Quad Core Intel Xeon, Mac OS X Server 10.6.7, php 5.3.4, Xcode 4.0.2.
This post will live forever 🙂

ben says:

worked great even though my source was 5.3.6 yet installed php is 5.3.4 (couldn’t find 5.3.4 source)

Ivan Novak says:

This worked wonders.
Running MBA 2.13 GHz Intel Core 2 Duo, Mac OS X 10.6.7, php 5.3.4, Xcode 4.0.2.
Thank you!

You deserve more than just comments thanking you, but that’s all I can do right now. You made something complicated simple. Thanks.

Cory says:

I have tried this 10 times, installing and then removing and then reinstalling. Every time it is the same thing, it all goes great and everything installs correctly, but when I check the phpinfo file no mcrypt. I have killed all the httpd processes, and only started apache from the preferences, and that didn’t work. So I tried it the other way around, and only started apache with apachectl. I tried changing the extension from to /usr/lib/php/extensions/no-debug-non-zts-20090626/ (where the shared extension was installed) and no joy there either.

I am running Snow Leopard 10.6.8 with PHP 5.3.4. I couldn’t find PHP 5.3.4 so I used 5.3.6 since some other posters said it worked just fine.

Cory says:

Nevermind, fixed it. It was a problem way back up in the php.ini file. There was a syntax error in the error reporting stuff. Ironic.

Glad you got it straightened out.

kristina says:

any chance you could share that syntax error cory?

Thanks Michael. Your tutorial worked without modification on OS X 10.6.7, a (installed) PHP 5.3.4 base, libmcrypt 2.5.8, and the PHP 5.3.6 source.

Thanks for saving me what I imagine would have been many hours digging around to figure out how to use mcrypt on OS X without recompiling PHP.

You’re certainly welcome.

Thomas says:

Thanks, worked for me on 10.6.8. A few caveats:
-The source for PHP 5.3.4 is available here:
-The install script for libmcrypt does not work if the path of your working src directory

[…] add mcrypt, these instructions work fine, with the following […]

Steve says:

If your looking for the older 5.3.4 try

rachanta says:

Thanks a lot.
The method works for 10.7 Lion as well well with xcode 4.2 installed.

rachanta says:

For Lion
Replace MACOSX_DEPLOYMENT_TARGET=10.6 with MACOSX_DEPLOYMENT_TARGET=10.7. Everything else in the procedure remain the same.

arseniy says:

worked for me (macos 10.6.8, xcode 4.2, php 5.3.4)! many thanks! )

ds handaru says:

dear michael…
I got a problem when installing the plugin libmcrypt,..

checking for g++… no
checking for c++… no
checking for gpp… no
checking for aCC… no
checking for CC… no
checking for cxx… no
checking for cc++… no
checking for cl… no
checking for FCC… no
checking for KCC… no
checking for RCC… no
checking for xlC_r… no
checking for xlC… no
checking for C++ compiler default output file name… configure: error: C++ compiler cannot create executables
See `config.log’ for more details.

and i can’t execute “make -j6”
how to solution for this case..
I useing Snow Leopard 10.6.8, Xcode 3.2.3, PHP 5.3.4.

please Help



No compiler, or not properly configured. Upgrading XCode to 4.0 should do the trick.

ds handaru says:

I’ve tried to update to Xcode 4.2, but mcrypt still not running, I’ve tried to do the installation or reconfiguration,
when execute “make-J6”

….. make -j6make

all-recursiveMaking all in modulesMaking all in algorithms
make[3]: Nothing to be done for `all’.
Making all in modes
make[3]: Nothing to be done for `all’.
make[3]: Nothing to be done for `all-am’.
Making all in include
make[2]: Nothing to be done for `all’.
Making all in lib
make[2]: Nothing to be done for `all’.
Making all in src
make[2]: Nothing to be done for `all’.
Making all in doc
make[2]: Nothing to be done for `all’.

and when execute “make sudo install”
test -z “/usr/local/share/aclocal” || /bin/sh ../mkinstalldirs “/usr/local/share/aclocal”
/usr/bin/install -c -m 644 ‘libmcrypt.m4’ ‘/usr/local/share/aclocal/libmcrypt.m4′
Making install in src
make[2]: Nothing to be done for `install-exec-am’.
make[2]: Nothing to be done for `install-data-am’.
Making install in doc
make[2]: Nothing to be done for `install-exec-am’.
test -z “/usr/local/man/man3” || /bin/sh ../mkinstalldirs “/usr/local/man/man3”
/usr/bin/install -c -m 644 ‘./mcrypt.3’ ‘/usr/local/man/man3/mcrypt.3′
make[2]: Nothing to be done for `install-exec-am’.
make[2]: Nothing to be done for `install-data-am’.

so how about this problem, and how to make a solution..

Jeff Melton says:

This worked like a charm and the instructions were very straight forward!

[…] PHP PHP 5.3.1 (cli) (built: Feb 11 2010 02:32:22) Modifié, car j’étais encore à 5.2 (5.2.15 (cli) – built: May  5 2011 18:56:00) Mes extensions personnalisées (en 32 bit) ont disparu de /usr/lib/php/extensions : il faudrait la recompiler en 64 bit. : inutile de la remettre, elle fait parti de PHP 5.3 : inutile de la remettre, elle fait parti de PHP 5.3 :  il faudrait la recompiler en 64 bit. […]

Sinek Dragi says:


I’m following these steps and I just can’t pass compiling the mcrypt extension.
Stuck on:
.3.7/ext/mcrypt/include -I//SourceCache/php-5.3.7/ext/mcrypt/main -I//SourceCache/php-5.3.7/ext/mcrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -O3 -fno-common -arch i386 -arch x86_64 -c //SourceCache/php-5.3.7/ext/mcrypt/mcrypt.c -fno-common -DPIC -o .libs/mcrypt.o
//SourceCache/php-5.3.7/ext/mcrypt/mcrypt.c:283: error: ‘PHP_FE_END’ undeclared here (not in a function)
//SourceCache/php-5.3.7/ext/mcrypt/mcrypt.c:283: error: ‘PHP_FE_END’ undeclared here (not in a function)
lipo: can’t figure out the architecture type of: /var/tmp//ccYd5Z17.out
make: *** [mcrypt.lo] Error 1

Any help is more tan welcome.

[ Os: 10.6.8. Php 5.3.4.]

Sinek Dragi says:

Please ignore that.. Sorry, I used wrong php version (worked with 5.3.6.).

Mark says:

I did the same thing with 5.3.8. I went back to 5.3.4 and it went fine.

Jean-Yves says:

I was getting the same error. I am on SL 10.6.8 with PHP 5.3.8

As you say, switching to an earlier version, 5.3.6 in my case, solved this issue – I now have mcrypt installed.

Thanks to Michael and all the posters who have provided additional info. Phew, I needed mcrypt to get some work done by the deadline of tomorrow evening! 🙂

Needless to say I have bookmarked this page.

[…] with missing libraries, ssl etc. Found this article explaining how to add mcrypt as a module: Plugging mcrypt into php on Mac OS X Snow Leopard by Michael Gracie Thanks to Michaels wonderful article mcrypt is […]

JRWoodward says:

Please excuse the incomplete post and double post. Carpal tunnel syndrome makes my wrist spasm at the end of the day.
I have a partial install under Snow Leopard. Mcrypt still doesn’t show up in phypMyAdmin and I still get the error message.
I got no error messages but is not in the folder where it needs to be and is not anywhere on my HD. Libmcrypt is at /usr/local/lib and /usr/local/lib/libmcrypt but is not under /usr/lib/php/extensions in any folder. To get this far, I had to change the gcc symlink from gcc 4.2 to version 4, which eliminated the errors.

I don’t use phpMyAdmin, so I cannot opine on what’s happening there.

What version of Xcode?

Dan says:

Thanks. This was one of the most awesome set of installation instructions I’ve ever read. Reading previous user comments were also helpful when I made a few careless mistakes.
MacOSX version 10.6.7, PHP version 5.3.4

Liquidice says:

Excellent work – this went much quicker than I had expected.

And after 2 years… This is still a working solution 😀 cheers bro

kristina says:

i get everything installed and configured without issue, but it’s not showing up in phpinfo.php. i’ve made a clean install twice and can’t figure out what the problem is. i’ve tried

extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/


extension =

i have restarted apache and httpd multiple times. will someone please help me stop bashing my head against the wall?

Are you editing the php.ini file designated by “Loaded Configuration File” in the phpinfo() results?

kristina says:


eremiya says:

Great Post!! Thanks a lot!

Sjy2 says:

Worked like a charm on 10.7.2. Naturall I tried to be smart and upgrade to PHP 5.3.8 at the same time, but of course that would not work given the config file in the SDK is for 5.3.6. Following your instructions, all worked like a charm.

Thankyou, thankyou!

(Of course it didn’t fix the problem that led me to your blog posting in the first place, but I can at least rule out one variable, and that is worth a lot!)

Pip says:

Thanks Michael, this was a time saver. Just did it on PHP 5.3.6.

I only had one problem – I have a folder called “Libraries / SDKs” which ‘make install’ didn’t like. I renamed it to “Libraries_SDKs” and cleaned and remade the config and it worked perfectly.

When will I learn…!

James says:

Thank you for this article. It was extremely helpful. I am working with Snow Leopard 10.6.8 and needed to download PHP 5.3.6. Outside of that deviation, I followed the instructions to the letter and everything worked perfectly.

Thanks again.

Joseph McCarthy says:

I have run into a problem, which was the adding of the extension to the php.ini file. You can not place the extension name as The full path should be give to the .so file.

This problem was on OS X 10.6.9 with the PHP build 5.3.6.


Remon Pel says:

Great tutorial.
For OSX Lion you can use 10.7 for MACOSX_DEPLOYMENT_TARGET but don’t forget to use ./configure –with-php-config=/Developer/SDKs/MacOSX10.7.sdk/usr/bin/php-config as well.

Jonathan says:

I have tried and tried, re installed etc etc

Installing libcrypt is fine, but when I come to install mcrypt, I get the same as Ward,

configure: error: Sorry, I was not able to diagnose which libmcrypt version you have installed.

I really dont know how to enable this damn, thing.

Followed the instructions above over n over. Correctly.

What could this be?

Versions correct (note that the post is now pretty old, and PHP, XCode have changed)? Has libmcrypt been previously installed on the machine?

Phil says:

Im getting the same error. I don’t think that mcrypt has been installed in this computer before.

Is there a way to uninstall everything and restart from scratch?

I just found one easy way to install mcrypt without the manual process..

check this:

It worked in one of my 10.6.8 OS X Server.


Danang says:

awesome.. it looks easy to do for me (new user of mac)
but I have some trouble to get compatible Xcode for my Mac OS X 10.6.8. I lost my CD, I’m trying to google the compatible Xcode but I couldn’t find one.
I used to uninstalled my xcode because i thought I’m not gonna need it (I only work with PHP)
any one can help me please… 🙁

tried this on 10.6.8 server, php 5.3.8.
make -j6 failed with error:
lipo: can’t figure out the architecture type of: /var/tmp//ccCarOjS.out
make: *** [mcrypt.lo] Error 1
What might be the reason?

JB says:

I just deleted the line in mcrypt.c that was causing an error.

For me on 10.6.8 it was line 283.

Ivan Vasquez says:

Got the same, due to this previous error:

error: ‘PHP_FE_END’ undeclared here (not in a function)

all I needed to do was follow this instructions and replaces all occurrences of PHP_FE_END with {NULL,NULL,NULL} .

This worked perfectly on Lion, but upgrading to Mountain Lion removed my progress with mcrypt. I redid all of this and had to make one change to get it to work for me.

Instead of compiling the mcrypt extention with the flag:

I had to use:

I’m not sure if this was just my system, but hopefully it’s useful to someone else.

Laura says:

After many hours and repeated attempts at plugging mcrypt into php, I stumbled across this post and boy am I thankful!

Thank you!!! I’m finally able to move on and get phpmyadmin installed, which depended on mcrypt.

mz says:

Thanks for this!
I had this error:
error: ‘PHP_FE_END’ undeclared here (not in a function)
Then i found this suggestion:
” You can avoid this by editing the file mentioned in the error message and replace all occurrences of PHP_FE_END with {NULL,NULL,NULL} .”
in this site
Run again make -j6 and sudo make install
And works perfect.
So thanks to both sites.

Marc Herman says:

Historic! I can’t believe I have done this. Thanks!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.