Centos – How to install mcrypt in dual PHP version CentOS 6

centoscentos6lampphp-mcryptrpm

I have two parallel versions of PHP installed on CentOS 6.5 via this method

[root@host ~]# php -i | grep "PHP Version"
PHP Version => 5.3.3
[root@host ~]# /opt/rh/php54/root/usr/bin/php -i | grep "PHP Version"
PHP Version => 5.4.16

The installs came from

[root@host ~]# rpm -q php php-mcrypt
php-5.3.3-27.el6_5.1.x86_64
php-mcrypt-5.3.3-3.el6.x86_64
[root@host ~]# rpm -q php54 php54-mcrypt
php54-1-7.el6.centos.alt.x86_64
package php54-mcrypt is not installed
[root@host ~]# rpm -q libmcrypt
libmcrypt-2.5.8-4.el6.art.x86_64
[root@host ~]# rpm -q libmcrypt-devel
libmcrypt-devel-2.5.8-4.el6.art.x86_64

On sites running PHP 5.3.3, mcrypt works fine. I need to make mcrypt available to the sites running 5.4.16. Naturally I tried yum install php54-mcrypt, but that returns No package php54-mcrypt available.. The following repos are enabled:

asl-4.0 
base 
epel 
extras 
scl 
updates 
virtualmin 
virtualmin-universal

So I searched for an RPM, and found this one. But if I try to install this RPM, it tries to update the currrent PHP mcrypt, which I need to keep running for sites on 5.3.3. I'm under the impression that php-mcrypt needs to be an exact to the php version and it's not backwards compatible.

I need to install mcrypt for PHP 5.4.16, where PHPZTS="" and PHPAPI=20100525. How can I do this?

Best Answer

I used rpm2cpio to convert the only suitable .rpm file I found into a cpio archive on standard out.

$ rpm2cpio php-mcrypt-5.4.16-1.el6.x86_64.rpm | cpio -idmv

I then copied mcrypt.so an mcrypt.ini to the proper folders for the PHP 5.4 install.

Voilá, mcrypt works now!

Related Topic