This article provides a guide for how to enable Mcrypt for PHP 7.2 and later in cPanel server. The Mcrypt PHP extension was deprecated by PHP after 7.1. Some applications still recommend this extension, however, so this guide provides a workaround for enabling Mcrypt extension on PHP 7.2+ in cPanel servers.
Enable Mcrypt for PHP 7.2 and Later in cPanel Server
To enable the Mcrypt extension for PHP 7.2+, follow the steps below:
- Login to the server as root user
- Run the following commands from SSH terminal:
yum install epel-release -y yum install libmcrypt -y yum install libmcrypt-devel -y
- Find the binaries for PECL for all versions of PHP installed on the server:
find /opt/cpanel/ -iname pecl | grep bin
- Check the output to confirm PECL binaries of the cPanel installation:
root@cpanel [~]# find /opt/cpanel/ -iname pecl | grep bin /opt/cpanel/ea-php72/root/usr/bin/pecl /opt/cpanel/ea-php73/root/usr/bin/pecl /opt/cpanel/ea-php74/root/usr/bin/pecl
/opt/cpanel/ea-php80/root/usr/bin/pecl /opt/cpanel/ea-php81/root/usr/bin/pecl
/opt/cpanel/ea-php82/root/usr/bin/pecl
/opt/cpanel/ea-php83/root/usr/bin/pecl root@cpanel [~]# - For each PHP version, run the following command (modify the commands for the PHP versions):
/opt/cpanel/ea-php72/root/usr/bin/pecl install mcrypt
- Example commands:
printf "\n" | /opt/cpanel/ea-php72/root/usr/bin/pecl install mcrypt
printf "\n" | /opt/cpanel/ea-php73/root/usr/bin/pecl install mcrypt
printf "\n" | /opt/cpanel/ea-php74/root/usr/bin/pecl install mcrypt
printf "\n" | /opt/cpanel/ea-php80/root/usr/bin/pecl install mcrypt
printf "\n" | /opt/cpanel/ea-php81/root/usr/bin/pecl install mcrypt
printf "\n" | /opt/cpanel/ea-php82/root/usr/bin/pecl install mcrypt
printf "\n" | /opt/cpanel/ea-php83/root/usr/bin/pecl install mcrypt - After each of the above commands, confirm the query (press Enter to continue):
libmcrypt prefix? [autodetect] :
- Repeat for each PHP version.
Conclusion
You have now enabled Mcrypt PHP extension for PHP 7.2+ on cPanel server.