I found out that when I wanted to use phpmyadmin, it asked for the libmcrypt module. So here is how I added mcrypt to PHP:

First download the libmcrypt sourcecode (I’ve used version 2.5.8).

First you need to unpack the source code and decide if you need the 32 bits or 64 bits version (of your apache/php installation).

for 64 bits use:

CFLAGS="-arch x86_64" \
CXXFLAGS="-arch x86_64" \
./configure --disable-posix-threads

for 32 bits use:

./configure --disable-posix-threads

For all versions use:

make

To compile and:

sudo make install

To install the library.

Next step is to recompile the php installation as described on these two pages:
Compiling PHP in 32 bits mode on Leopard
Compiling PHP in 64 bits mode on Leopard

The only change you need to make is to add:

–with-mcrypt

To the configure statement and it will include this library for you.

For example:

./configure --prefix=/usr/local/php5 \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
--with-zlib \
--with-zlib-dir=/usr \
--with-openssl \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-sockets \
--with-mcrypt \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-apxs2=/usr/local/apache2/bin/apxs