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

First download the libmcrypt sourcecode. Don’t download the regular mcrypt package!

First you need to unpack the source code and then use:

./configure --disable-posix-threads
make
sudo make install

To compile and install the library.

Next step is to recompile the php installation as described on this page: Compiling PHP.

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-config-file-path=/etc \
  --with-zlib \
  --with-zlib-dir=/usr \
  --with-openssl \
  --without-iconv \
  --enable-exif \
  --enable-ftp \
  --enable-mbstring \
  --enable-mbregex \
  --enable-sockets \
  --with-mysql=mysqlnd \
  --with-pdo-mysql=mysqlnd \
  --with-mysqli=mysqlnd \
  --with-mcrypt \
  --with-apxs2=/usr/local/apache2/bin/apxs