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; and
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… extension=mcrypt.so
Restart Apache – you should be all set (again), according to phpinfo():













September 29th, 2009 at 6:13 pm
Thanks so much for this, very easy to follow and worked a treat!
October 12th, 2009 at 10:39 pm
Perfect! Thanks so much. Worked a treat!
Will this work for all extensions or are there some that shouldn’t be loaded dynamically?
October 13th, 2009 at 8:24 pm
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.
October 15th, 2009 at 2:05 pm
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.
October 15th, 2009 at 4:18 pm
Thanks for that Donna! And I’ll note I had help, and thank them again.
October 18th, 2009 at 3:07 pm
Excellent! Finally something that worked.
Thanks for the clear descriptions.
October 20th, 2009 at 1:06 am
it worked like a charm… Thank you.
October 21st, 2009 at 5:29 pm
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.
October 21st, 2009 at 5:50 pm
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.
October 21st, 2009 at 6:04 pm
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.
Bryan.
October 21st, 2009 at 8:59 pm
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!
October 27th, 2009 at 4:11 pm
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…
October 27th, 2009 at 4:17 pm
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.
October 28th, 2009 at 5:17 am
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
October 28th, 2009 at 8:30 am
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.
October 28th, 2009 at 9:45 am
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
October 28th, 2009 at 9:49 am
Sorry!
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
October 28th, 2009 at 10:15 am
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.
October 28th, 2009 at 10:33 am
I’m so stupid!
Everything solved after updating Xcode
Really sorry.
Regards, Magnus
October 28th, 2009 at 11:02 am
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).
magnus
October 29th, 2009 at 8:31 am
I take that back. The old Xcode wouldn’t have had the 10.6 dev environment.
October 30th, 2009 at 5:57 pm
Thanks so much for the great tutorial. This worked like a charm.
November 2nd, 2009 at 10:10 am
This helped. Thanks!
November 3rd, 2009 at 9:14 am
@Paul/Muhammad – No prob. Glad it worked out for you.
November 6th, 2009 at 1:15 pm
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.
November 6th, 2009 at 1:21 pm
[...] 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 [...]
November 7th, 2009 at 4:59 pm
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.
November 9th, 2009 at 10:42 pm
perfecto! thanks
November 11th, 2009 at 8:47 am
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….
November 11th, 2009 at 10:15 am
crucco – Do you mean Apache won’t start?
November 11th, 2009 at 8:16 pm
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
November 11th, 2009 at 9:07 pm
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.
November 12th, 2009 at 7:38 am
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.
November 12th, 2009 at 8:27 am
@crucco
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
November 12th, 2009 at 10:10 am
@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).
November 12th, 2009 at 1:26 pm
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.
November 12th, 2009 at 2:59 pm
@michael
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.
November 13th, 2009 at 9:30 am
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.
November 13th, 2009 at 10:06 am
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….
November 15th, 2009 at 11:28 am
Thanks so much for the tutorial — worked like a charm!
November 15th, 2009 at 12:33 pm
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….
November 15th, 2009 at 11:22 pm
crucco – Glad you got it working. Jared Howard (above) had a similar problem. Not dumb…just technology!
November 28th, 2009 at 10:23 am
I get to the point where I ./configure php. But I end up with
Notice: Following unknown configure options were used:
–with-php-config=/Developer/SDKs/MacOSX10.6.sdk/usr/bin/php-config
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.
November 28th, 2009 at 11:51 am
Stephen – Do you have the latest developer tools installed (in other words, does /Developer/SDKs/MacOSX10.6.sdk exist)?
November 29th, 2009 at 7:33 am
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 ).
November 30th, 2009 at 1:16 am
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.
December 2nd, 2009 at 5:10 am
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)
December 2nd, 2009 at 7:26 am
Problem solved. After downloading PHP 5.3.0 from Apples Open Source Server the installation worked without a problem.
December 2nd, 2009 at 2:05 pm
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?
Thanks,
Jesse
December 2nd, 2009 at 2:15 pm
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.
December 2nd, 2009 at 2:45 pm
Thank Michael.
Can I get away with just installing the extension “mycrpt.so” 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 mycrypt.so 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.
Jesse
December 2nd, 2009 at 3:01 pm
It should stand alone (but that does assume the environments are identical).
December 2nd, 2009 at 3:17 pm
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.
December 5th, 2009 at 6:34 pm
Thanks so much!
… it works great
very clearly, precise and easy to understand tutorial, thanks again for sharing this!
December 14th, 2009 at 6:54 pm
Michael,
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!
December 15th, 2009 at 11:03 am
Super tutorial, thank you so much…
December 15th, 2009 at 12:29 pm
@Kenny – Shouldn’t be, but wondering…have you done your own PHP compilation?
@bveale – You’re welcome!
December 15th, 2009 at 1:24 pm
@Michael
No, I enabled the built in PHP via uncommenting line115 in the httpd.conf file.
December 15th, 2009 at 3:44 pm
Ok. I’m assuming PHP is running, and that the compiles worked without error. Dynamic loading enabled, and you have extension=mcrypt.so on a line under dynamic extensions?
Also, search for mcrypt.so, and post where you found it. If you found it.
December 15th, 2009 at 10:42 pm
My mcrypt.so file is located in /usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so
December 16th, 2009 at 12:52 am
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
December 16th, 2009 at 9:56 am
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!
December 16th, 2009 at 7:45 pm
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?
December 17th, 2009 at 5:55 pm
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.
December 17th, 2009 at 6:13 pm
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.
December 20th, 2009 at 6:36 pm
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
thanks
-dale
December 20th, 2009 at 6:43 pm
“just using the source to do the builds”
December 25th, 2009 at 1:05 pm
You were so helpful to me! Thanks a lot!
December 26th, 2009 at 3:22 am
Thanks mate! It works fine. I can use now my phpMyAdmin without giving me the nuisance error for mcrypt.
More power to you!!!
December 27th, 2009 at 4:35 am
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.
January 5th, 2010 at 6:08 pm
@Paul did you fix your #2002 error with mysql? I’m getting the same think:(
January 5th, 2010 at 6:18 pm
@Paul actually I found a fix for the MySQL #2002 error in phpmyadmin, I had to change config.inc.php from using “localhost” to “127.0.0.1″ in this line:
old:
$cfg['Servers'][$i]['host'] = ‘localhost’;
new:
$cfg['Servers'][$i]['host'] = ’127.0.0.1′;
hope that helps.
January 5th, 2010 at 9:18 pm
Thanks ThinkMud that worked. Had to change my php apps from localhost to 127.0.0.1 for them to work also.
Cheers
January 5th, 2010 at 9:28 pm
There has to be something we can set somewhere for MySQL to make localhost point to 127.0.0.1, 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 127.0.0.1 instead of locahost because all my live sites have localhost. I’ll dig around more tomorrow and figure it out:)
January 13th, 2010 at 2:01 pm
I am just one more who is very grateful for this information! Thanks a lot!!
January 14th, 2010 at 11:10 am
[...] 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 mcrypt.so [...]
January 16th, 2010 at 9:09 am
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!
January 18th, 2010 at 9:12 pm
@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 127.0.0.1 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: http://maestric.com/doc/mac/apache_php_mysql_snow_leopard
January 20th, 2010 at 5:57 pm
You are definitely welcome Brent.
January 20th, 2010 at 6:05 pm
@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!
January 23rd, 2010 at 6:44 am
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:
http://www.gen-x-design.com/archives/recompiling-php-5-3-on-snow-leopard-with-freetype-support/
(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.
Cheers!
January 24th, 2010 at 1:10 am
Micheal thanks much for writing this up. Saved me a bunch of time fishing for answers.
January 28th, 2010 at 1:26 pm
Great thanks!!!
February 5th, 2010 at 12:50 am
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.]
Thanks!
February 5th, 2010 at 6:55 am
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.
February 5th, 2010 at 2:07 pm
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 libphp5.so
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 activate-entropy-php.py
-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
February 5th, 2010 at 5:46 pm
Laura –
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”
February 5th, 2010 at 7:06 pm
Thanks, Michael. After many hours of fighting, I just installed MAMP, so I guess I took a short cut ;}
February 6th, 2010 at 9:52 pm
Thank you Michael, your advice worked without a flaw…good luck merging the fly-fishing….
February 10th, 2010 at 3:34 pm
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.
February 11th, 2010 at 8:52 am
@Maryann – I’m assuming “all went well” means compile completed without errors. Check to make sure that mycrypt.so 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.
February 11th, 2010 at 9:17 am
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!!
February 11th, 2010 at 9:47 am
From above -
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.
February 21st, 2010 at 9:07 am
Big thanx man !!. All worked well. Thx again.
February 21st, 2010 at 9:09 pm
@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!
February 21st, 2010 at 9:52 pm
I got it all working, worked great! (finally!)
February 22nd, 2010 at 10:02 pm
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)
February 24th, 2010 at 12:52 pm
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?
February 26th, 2010 at 2:14 pm
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)
February 26th, 2010 at 4:41 pm
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.
February 27th, 2010 at 8:24 am
Big thanks to michael mcrypt works now after long search in internet. Great work and easy to install.
March 7th, 2010 at 5:17 am
@Joel: I ran into the same problem and found a solution here: http://discussions.apple.com/thread.jspa?threadID=2219620&tstart=0
Go into cd /SourceCache/php-5.3.0/ext/mcrypt before you run phpize.
HTH
March 7th, 2010 at 5:54 am
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 (linux.softpedia.com 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!
March 15th, 2010 at 3:36 am
Thanks! Worked flawlessly on first try =)
March 18th, 2010 at 8:39 am
Fantastic! Worked like a charm – even for a novise like me!
March 25th, 2010 at 4:12 am
nice tutorial. Thank you !
March 29th, 2010 at 6:03 am
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.
March 29th, 2010 at 6:07 am
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.
March 29th, 2010 at 6:41 am
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.
April 2nd, 2010 at 7:36 am
Worked perfectly. Cheers.
April 2nd, 2010 at 10:03 am
Excellent
Thank you very much.
April 17th, 2010 at 11:50 am
Thanxs ! This tutorial is awesome !
April 20th, 2010 at 6:55 am
Oh Man, this worked wonders. Thanks a billion! I was struggling with Snow Leopard’s lack of mcrypt.
April 25th, 2010 at 7:09 am
Thank you sir. Excellent work.
April 30th, 2010 at 5:08 pm
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
/private/var/db/receipts/ch.entropy.php.mcrypt.bom
/private/var/db/receipts/ch.entropy.php.mcrypt.plist
/usr/local/bin/libmcrypt-config
/usr/local/include/mcrypt.h
/usr/local/include/mutils/mcrypt.h
/usr/local/lib/libmcrypt
/usr/local/lib/libmcrypt.4.4.8.dylib
/usr/local/lib/libmcrypt.4.dylib
/usr/local/lib/libmcrypt.dylib
/usr/local/lib/libmcrypt.la
/usr/local/man/man3/mcrypt.3
/usr/local/share/aclocal/libmcrypt.m4
/usr/share/file/magic/mcrypt
Should i just start over? Find some tutorials on uninstalling php? Mysql?
:/
Thanks for any help
May 5th, 2010 at 6:44 pm
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.
May 6th, 2010 at 7:39 am
Brilliant! Worked exactly as stated with 10.6.3, MySQL 5.1.46, and PHP 5.3.1.
So grateful that you published this!
May 9th, 2010 at 4:34 pm
Hey Michael! Thanks very much for this tutorial; works great!!
May 13th, 2010 at 8:18 am
Fantastic guide, Michael. This was quick and painless on OS X 10.6.2/PHP 5.3.0
May 18th, 2010 at 2:10 pm
Fantastic tutorial, it also works wiht the 5.3.1 php
thank you so much…
May 20th, 2010 at 9:44 am
[...] 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 [...]
May 21st, 2010 at 2:42 pm
Thank you very much for this tutorial. It works very well.
Merci beaucoup pour ce tutorial. Ca marche à merveille.
June 1st, 2010 at 9:40 am
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?
June 1st, 2010 at 10:06 am
@Mat – System root, which can be at your admin user. So, at /Macintosh_HD will do.
June 3rd, 2010 at 6:43 pm
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!
June 4th, 2010 at 9:50 am
Sorry for my naivety …where do I find the directory /etc
June 4th, 2010 at 10:10 am
It’s under root.
June 4th, 2010 at 10:34 am
Does this /etc folder exist by default, or is it added as a result of the process as above?
June 4th, 2010 at 3:01 pm
By default.
June 7th, 2010 at 7:57 am
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!
June 10th, 2010 at 12:18 pm
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 ?
June 10th, 2010 at 12:34 pm
The instructions are intended to work exactly as stated. Could be wrong directory, or wrong source code download.
June 10th, 2010 at 1:29 pm
yep, it was a minor mistake from my side. tnx for this guide.
June 12th, 2010 at 12:22 pm
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.
June 14th, 2010 at 4:07 am
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!
June 14th, 2010 at 9:13 am
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..
June 14th, 2010 at 1:39 pm
Kiran – Could be wrong source, wrong directory…even a typing error.
Best suggestion…start over.
June 14th, 2010 at 2:11 pm
i dont know how, i started all over again with the same files and everything works just fine… thanks a lot
June 21st, 2010 at 11:51 am
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,
stooky
June 21st, 2010 at 12:41 pm
a) it should
b) yep, root, like /Macintosh HD
c) yes
June 21st, 2010 at 3:31 pm
cheers michael
worked smothly on
macbook with php 5.3.1
macmini with php 5.3.2
rgds,
stooky
June 23rd, 2010 at 9:40 pm
Hi Michael,
I have followed your instructions to the T, everything through terminal worked with no errors however when I run php.info i cant see mcrypt. Ive restarted websharing but still no joy.
Any suggestions??
cheers in advance.
aziwaan
June 23rd, 2010 at 9:49 pm
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.
June 23rd, 2010 at 10:51 pm
Scratch that last one, I kooked it, had extension=mcrypt.so commented out in php.ini : (
Thanks again.
June 28th, 2010 at 10:55 am
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…
June 28th, 2010 at 1:14 pm
[...] 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. [...]
June 29th, 2010 at 7:42 pm
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.
July 6th, 2010 at 5:20 pm
Kudos! – This worked wonderfully!
July 11th, 2010 at 6:53 am
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).
July 11th, 2010 at 6:57 am
I just saw that somebody already mentioned the tcsh thing… sorry
July 13th, 2010 at 4:03 am
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: http://meshfields.de/install-magento-on-unix/
July 19th, 2010 at 5:26 pm
Worked like magic. I used this for phpMyAdmin after installing mysql.
Great tutorial.
July 19th, 2010 at 5:46 pm
Excellent!
July 21st, 2010 at 8:44 pm
[...] 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 [...]
July 21st, 2010 at 9:29 pm
Thank you!!!
July 29th, 2010 at 12:39 pm
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).
July 29th, 2010 at 1:41 pm
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.
July 30th, 2010 at 10:37 pm
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:
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 –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?