wiki:BuildPHPWithMcrypt

Building PHP with mcrypt support, to allow encryption in Maia Mailguard

Before installing encryption, read AboutEncryption

from Paul Westbrook

In order to support the encryption feature of Maia Mailguard, PHP needs to be built with support for mcrypt. Most distributions do not include this support in PHP by default, so the PHP packages need to be rebuilt to include it. The following steps can be used to build a php rpm that includes this support. These steps can be modified for any distribution that uses rpms for installation.

  1. Download the source rpm from Red Hat (for your distribution)
  2. rpm -Uvh php-*.src.rpm
  3. cd /usr/src/redhat/SPECS/
  4. edit php.spec to include "--with-mcrypt "
  5. rpmbuild -ba php.spec
  6. cd /usr/src/redhat/RPMS/i386
  7. rpm -Uvh php*.rpm
  8. restart apache

Red Hat / Fedora Core Addition from Jarod Wilson

There's a bit more to it than that. You need mcrypt libs installed, and they should be a build requirement for the modified php.spec. Personally, I grabbed libmcrypt and libmcrypt-devel from dag.wieers.com (I'm running FC3), modified the php spec file for mcrypt support, modeled after mhash support (my spec file is attached), and rebuilt with rpmbuild -bb --with mcrypt php-4.3.9-mcrypt.spec. Also note that there's a bug in the php 4.3.9 code that breaks parallel builds in some cases, so you may need to use 'rpmbuild -bb --define "_smp_mflags %{nil}" --with mcrypt php-4.3.9-mcrypt.spec. I've used this same spec file and the FC3 php source rpm to build on RHEL3 as well.

Debian & PHP with MCRYPT

A much easier process :)

  1. apt-get install php4-mcrypt
  2. egrep -R /etc/php4/ mcrypt\.so *
  3. If there were no results from the egrep command, add "extension=mcrypt.so" to php.ini (usually the apt-get step takes care of editing php.ini for you automatically)
  4. Restart Apache

SUSE >= 9.1

  • It's available in default install. Use yast to install the php4-mcrypt module.

Back to FAQ

Last modified 14 years ago Last modified on Mar 20, 2009, 4:31:41 PM

Attachments (1)

Download all attachments as: .zip