How to install mcrypt on mac osx10.7 and osx10.6
There a lot of php opensouce software that requires mcrypt and it took me a few hours to get mcrypt installed and working natively on my mac, after reading many many tutorials. I originally tried to go down the homebrew (package manager) route but this didn’t work. So here are the steps I followed.
All the following steps are in terminal
Find out your version of php you are using, what ever it says make sure in the following instructions you replace 5.3.10 (my version at the time of writing) with the version you have. Also if you are using a different version of OSX (i.e. 10.6) then make sure you replace all bit that say 10.7.
Download the required packages
mkdir /tmp/mcrypt cd /tmp/mcrypt curl --location -s http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download | tar -zx curl --location -s http://us.php.net/get/php-5.3.10.tar.gz/from/nl.php.net/mirror | tar -zx
Install and Make
cd /tmp/mcrypt/libmcrypt-2.5.8 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 make -j6 sudo make install
cd /tmp/mcrypt/php-5.3.6/ext/mcrypt/ phpize 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=/usr/bin/php-config make -j6 sudo make install
Delete temp folder
cd ~ && rm -rf /tmp/mcrypt
Activate in PHP by adding the following line to the bottom of /ext/php.ini (you can open this file by typing sudo open /etc/php.ini or if that doesn’t work sudo nano /etc/php.ini
sudo apachectl restart
If the above doesn’t work, go to system preferences -> sharing and turn off web sharing and turn it back on again.
Test the install
php --info | grep crypt
You should see something like mcrypt enabled.