How to Install PHP 5.3.3 mcrypt Extension on CentOS 5.7 64-bit with Yum Conflict Resolution


4 views

When working with CentOS 5.7's default repositories, you'll encounter dependency conflicts between PHP 5.3 and the system's default PHP 5.1 packages. The key error occurs because:

php53-common conflicts with php-common

First, check available mcrypt packages for PHP 5.3:

yum --enablerepo=remi list php53* | grep mcrypt

If no packages appear, you'll need to:

  1. Add the EPEL and Remi repositories:
rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
  1. Install the specific version with:
yum --enablerepo=remi install php53-mcrypt

If repository options fail, compile from source:

wget http://pecl.php.net/get/mcrypt-1.0.1.tgz
tar -zxvf mcrypt-1.0.1.tgz
cd mcrypt-1.0.1
phpize
./configure
make
make install

Then add to php.ini:

extension=mcrypt.so

Create a test script:

<?php
phpinfo();
?>

Look for the mcrypt section in the output.

  • Check loaded modules: php -m | grep mcrypt
  • Verify PHP version: php -v
  • Inspect configuration: php --ini

When trying to install mcrypt for PHP 5.3.3 on CentOS 5.7 64-bit, you might encounter dependency conflicts. The default php-mcrypt package (version 5.1.6) conflicts with PHP 5.3 installations because it requires php-common, which isn't compatible with php53-common.

Running:

yum install php53-mcrypt

Returns:

No package php53-mcrypt available

This happens because CentOS 5.7's default repositories don't include a php53-mcrypt package.

The most reliable way to resolve this is by adding the EPEL (Extra Packages for Enterprise Linux) repository:

rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Then install mcrypt:

yum install php-mcrypt --enablerepo=epel

If the EPEL method doesn't work, you can compile mcrypt manually:

wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar -xvzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install

Then recompile PHP with --with-mcrypt flag.

Create a test PHP file:

<?php
phpinfo();
?>

Look for the mcrypt section in the output. If it's missing, check your PHP error logs.

The same approach applies to mhash:

yum install php-mhash --enablerepo=epel