In this short tutorial we will show 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
- Check extensions are loaded
Alright lets get started.
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
If it installs successfully 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 ~]#
I hope you enjoyed this tutorial and found it helpful.