[UPDATE]: Updated for OSX 10.10 Yosemite [/UPDATE]
In my attempts to run phpMyAdmin on my development Mac I found this tutorial but, alas, it didn’t work. It resulted in numerous errors (like this one: lipo: can’t figure out the architecture type of: /var/folders/v6/nrfc_5hn12g91vzw8vff44m00000gn/T//cchRI7wl.out) and, as you guessed, the mcrypt extension did not work.
This post is the third post in a series to build the “perfect” setup. See ‘The “Ultimate” Guide …’ for a complete list. It is also referenced from the first post in this series, so you MIGHT already have done this :)
I found this tutorial and it works… sort of… and because it’s not entirely correct, I have copied and pasted a bit and now it is correct :) Also the tutorial is for 10.6 and we’re on 10.7, so I have compensated for that as well.
Of course, this is based on my OSX Lion 10.9 installation and I have Xcode 5.01 installed.
Fire up your terminal and do this;
Now you will see the version number of your PHP; you will need to match the source version with this. Mine is 5.4.17 for PHP and I downloaded the 2.5.8 version of mcrypt. If you use different versions, then substitute the correct version numbers.
mkdir /tmp/source && cd /tmp/source
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://nl3.php.net/get/php-5.4.17.tar.gz/from/nl1.php.net/mirror | tar -zx
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/php /usr/include/php
MACOSX_DEPLOYMENT_TARGET=10.9 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
MACOSX_DEPLOYMENT_TARGET=10.9 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=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/bin/php-config
sudo make install
You may encounter a problem during build if some C modules aren’t available. If you get an error like this
error: 'PHP_FE_END' undeclared here (not in a function)
Same thing might happen with function ZEND_MOD_END .
After fixing, issue the commands
sudo make install
This should build now.
I have no idea what effect this will have on the end-result, but at least it builds :)
Thank you, Homer, for this great tip.
now remove the temporary files
cd ~ && rm -rf /tmp/source
Edit your PHP configuration
sudo nano /etc/php.ini
if “New file” is shown, please copy php.ini.default to php.ini first.
[ ! -f "/etc/php.ini" ] && sudo cp /etc/php.ini.default /etc/php.ini
other tutorials tell you to set
Some versions of OSX come with a default php.ini with an mcrypt section (mine does in 10.8 and 10.9, but did NOT in 10.7 which was an upgraded 10.6 which was an upgraded 10.5…) and it MIGHT be needed to put this line in the mcrypt section. In NANO, you can search with CTRL+W. (Thank you Joshua)
Now restart your Apache
- click Apple > System Preferences > Sharing
- disable Web Sharing
- enable Web Sharing
If Web Sharing won’t come on, retrace your steps, you must have missed an error message.
If all goes well, Web Sharing will turn on
in your terminal type
php --info | grep crypt
you should see:
mcrypt support => enabled
Now you’re done!
August 2014: Updated for OSX 10.10 Yosemite
July 2013: Updated for OSX 10.9 Mavericks