I got a request to add mcrypt support to our Leopard server today and here is a brief step-by-step installation instruction. This works well under the current 10.5.8 server installation. It should also work for 10.6 (snow leopard), but I have not tried it. Before you start here are the requirements:
- Backup your system
- Install (and update) the latest XCode (I’ve got version 3)
- Install X11 client stuff from your server install DVD
- install X11 SDK stuff from your server install DVD
- Ensure you have server 10.5.8 (latest update as of Feb.04.2011)
- Make sure you have not tried to install mcrypt using another method. We need a “virgin” 10.5.8 install (as far as homebrew/local installs)
- BACKUP
Please note that this will add mcrypt support to php. This is NOT the same as compiling mcrypt.
Okay, so now that we have all the requirements, you need to get a command line window opened and get a root shell (sudo -i). The rest of this document assumes you’re typing the commands in a root shell.
There is one dependency that we need to clear before we actually get down and dirty and that is libmcrypt. Follow the instructions below to get this installed:
mkdir /SourceCache
cd /SourceCache
curl http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download -o libmcrypt-2.5.8.tar.bz2 -L
This is the latest version as of this writing (Feb.04.2011).
NOTE: If you’re compiling on a G5 machine you’ll need to tell the compiler that you want to build/configure for a ppc64 target so instead of the below configure command you need to use this:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=" -arch ppc64 -g -Os -pipe -no-cpp-precomp" CCFLAGS=" -arch ppc64 -g -Os -pipe" CXXFLAGS="-arch ppc64 -g -Os -pipe" LDFLAGS="-arch ppc64 -bind_at_load" ./configure --enable-shared
tar -xjvf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8/
./configure
make
make -n install
The last command will simulate the installation process. Make sure the stuff is getting installed in /usr/local/lib
make install
At this point you should have a working installation of libmcrypt. This next command prints out the current version of your php engine. In my case under 10.5.8 it’s php 5.2.14.
server:libmcrypt-2.5.8 root# php -v
PHP 5.2.14 (cli) (built: Oct 6 2010 16:57:10)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
Grab the appropriate php-5.2.XX.tar.bz2 file from php.net. I just grabbed the stock PHP 5.2.14, since I wanted a perfect match between my php engine and the extension. I transferred the file using sftp to the /SourceCache folder on the server.
NOTE: If you’re compiling on a G5 machine you’ll need to tell the compiler that you want to build/configure for a ppc64 target so instead of the below configure command you need to use this:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=" -arch ppc64 -g -Os -pipe -no-cpp-precomp" CCFLAGS=" -arch ppc64 -g -Os -pipe" CXXFLAGS="-arch ppc64 -g -Os -pipe" LDFLAGS=" -arch ppc64 -bind_at_load" ./configure --with-php-config=/Developer/SDKs/MacOSX10.5.sdk/usr/bin/php-config
cd /SourceCache
tar xjvf php-5.2.14.tar.bz2
cd /SourceCache/php-5.2.14/ext/mcrypt
phpize
./configure --with-php-config=/Developer/SDKs/MacOSX10.5.sdk/usr/bin/php-config
make
make test
make -n install
The last command will simulate the installation process. Make sure the stuff is getting installed in /usr/lib/php/extensions/no-debug-non-zts-20060613
make install
Now we need to modify our php.ini file and tell the php5 engine of the availability of this new module. To do this you need to copy php.ini.default to php.ini (in /etc directory). For details of why have a look at this article.
cd /etc
cp php.ini.default php.ini
Edit the newly created/copied php.ini using your favourite editor. Add the following line to the appropriate location (read the comments in the file to find the location):
extension=mcrypt.so
Still in the same file find the variable “extension_dir” and change it’s value to “/usr/lib/php/extensions/no-debug-non-zts-20060613” path instead of “./”. Save the php.ini and use the following command to see if mcrypt extensions are available:
server:etc root# php -i |grep mcrypt
mcrypt
mcrypt support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
Done. Restart Apache service from the server manager (just for the sake of completeness).
One response to “Adding mcrypt support to builtin php5 on OSX Leopard….”
Very very thanks.
The information for the configuration of the g5 has helped me.