Friday, November 15GNOME IT SOLUTIONS LLC

How to install mcrypt for PHP 7.2 and PHP 7.3 on Centos 7(cPanel)

how easy it is to install mcyrpt for PHP 7.2 and PHP 7.3 via Pecl for Easy Apache4 on Centos 7(cPanel).

PHP officially deprecated mcrypt as of PHP 7.1 and this causes issues for sites whos CMS still requires it but want to run later PHP versions. More about that official notice isĀ here.

Mcrypt installation process

  • Install epel-release repo
  • Install libmycrpt and libmcrypt-devel rpms needed for the PHP extensions.
  • Update all Pecl php versions.
  • Install Mcrypt PHP extensions via Pecl for PHP72 and PHP73
  • Restart Apache/Litespeed to activate the extensions

Install epel-release repo if you do not already have it installed

yum install epel-release

Install libmycrpt and libmcrypt-devel rpms needed for the PHP extensions.

yum install libmcrypt libmcrypt-devel

Update all Pecl php versions.

for version in $(ls /opt/cpanel|grep ea-php); do /opt/cpanel/${version}/root/usr/bin/pecl channel-update pecl.php.net; done

Install Mcrypt PHP extensions via Pecl for PHP72 and PHP73

/opt/cpanel/ea-php72/root/usr/bin/pecl install channel://pecl.php.net/mcrypt-1.0.1
/opt/cpanel/ea-php73/root/usr/bin/pecl install channel://pecl.php.net/mcrypt-1.0.2

It should look something like this at the end of each step.

Build process completed successfully
Installing '/opt/cpanel/ea-php72/root/usr/lib64/php/modules/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.1
Extension mcrypt enabled in php.ini
============
Build process completed successfully
Installing '/opt/cpanel/ea-php73/root/usr/lib64/php/modules/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.2
Extension mcrypt enabled in php.ini

Restart Apache/Litespeed to make the new PHP extensions active.

service httpd restart

Check for the mcrypt extensions showing.

for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do echo "PHP $phpver" ; /opt/cpanel/ea-php$phpver/root/usr/bin/php -m |grep -E 'mcrypt'; done

It will look something like this for the extensions if installed properly and httpd process was restarted.

[root@cpanel ~]# for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do echo "PHP $phpver" ; /opt/cpanel/ea-php$phpver/root/usr/bin/php -m |grep -E 'mcrypt'; done
PHP 71
mcrypt
PHP 72
mcrypt
PHP 73
mcrypt
[root@cpanel ~]#

GNOME cPANEL Hosting

Leave a Reply