Out with the old lion, in with the high altitude cat. Twice again, thanks goes out to previous commenters – this time it’s Mario, Max, and Rob, for the providing the right pieces to the puzzle. Onward…
The following instructions cater to those who a) are developing on OS X Mountain Lion 10.8.X, b) need the capabilities provided by mcrypt during their PHP development (such as installing Magento eCommerce), and c) do not want to completely recompile PHP or run MAMP. You’ll get mcrypt loading dynamically within PHP with these instructions.
First, you are going to need a few things…
1) libmcrypt-2.5.8, which you can pick up here; make sure to get libmcrypt and not mcrypt. To do this, click “Libmcrypt” then “2.5.8” and then chose the file named “libmcrypt-2.5.8.tar.gz”;
2) PHP 5.3.15 source, which you grab here; NOTE – You may update your OS X at some point, and PHP may get updated along with it – for the author’s run OS X 10.8.2 was being used. Use phpinfo() to check your version of PHP, and then download the PHP source for that version;
3) Xcode 4.5 tools, which you can pick up in the App Store; NOTE – you will also need the Command Line Tools (OS X Mountain Lion) for XCode, which you can pick up by selecting “Xcode/Open Developer Tool/More Developer Tools..” from the Xcode menu, then logging into your Apple Developer account;
4) Homebrew (http://mxcl.github.com/homebrew/) which can be installed by typing
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go/install)" at the command line.
First, 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.15/ext/mcrypt – now STOP!
Xcode 4.5 doesn’t include autoconf, so if you haven’t installed it yet see “needs” #4 above to install Homebrew, and once that is done, type
brew install autoconf. Now you can proceed…
Then configure as follows…
MACOSX_DEPLOYMENT_TARGET=10.8 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 then
make test and finally
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 Mountain 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…
Next: Enable PHP. PHP is not enabled by default – you will need to make a small modification to your /etc/apache2/httpd.conf file to get it going. You can do this with root power from the terminal using vim or emacs, or you can change the permissions on the file itself and the directories above from Finder info, then edit in XCode, and return the permissions to read-only thereafter. Take your pick – all you have to do is remove the “#” from in front of
LoadModule php5_module libexec/apache2/libphp5.so, then save.
Restart Apache, using
sudo apachectl start. NOTE: this used to be as easy as selecting Web Sharing from within System Preferences, but that option is gone in OS X 10.8 Mountain Lion. Now you use the terminal window.
You should be all set (again), according to phpinfo():
MG signing off (because despite all attempts to thwart, we have mcrypt running in PHP yet again)