The following instructions cater to those who a) are developing on OS X Lion 10.7.X, 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.6 source, which you grab here; ADDITIONAL NOTE: You may update your OS X at some point, and PHP may get updated along with it. Use phpinfo() to check your version of PHP, and then download the PHP source for that version.
3) Xcode 4.1 tools, which you can pick up in the App Store.
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.7 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
sudo make install
libmcrypt is ready – now for the PHP extension…
Move back to /SourceCache, then down to php-5.3.6/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.7 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.7.sdk/usr/bin/php-config
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 an OS X upgrade or a clean Lion install, 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():
MG signing off (now that we have mcrypt running in PHP once again)