How to Enable Mcrypt for PHP 7.2 and Later in cPanel Server


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:

  1. Login to the server as root user
  2. Run the following commands from SSH terminal:
    yum install epel-release -y
    yum install libmcrypt -y
    yum install libmcrypt-devel -y
  3. Find the binaries for PECL for all versions of PHP installed on the server:
    find /opt/cpanel/ -iname pecl | grep bin
  4. 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 root@cpanel [~]#
  5. 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
  6. Example commands:
    /opt/cpanel/ea-php72/root/usr/bin/pecl install mcrypt
    /opt/cpanel/ea-php73/root/usr/bin/pecl install mcrypt
    /opt/cpanel/ea-php74/root/usr/bin/pecl install mcrypt
    /opt/cpanel/ea-php80/root/usr/bin/pecl install mcrypt /opt/cpanel/ea-php81/root/usr/bin/pecl install mcrypt
    /opt/cpanel/ea-php82/root/usr/bin/pecl install mcrypt
  7. After each of the above commands, confirm the query (press Enter to continue):
    libmcrypt prefix? [autodetect] :
  8. Repeat for each PHP version.

Conclusion

You have now enabled Mcrypt PHP extension for PHP 7.2+ on cPanel server.

  • php, php extensions
  • 10 Users Found This Useful
Was this answer helpful?

Related Articles

Remove a Service from ChkServd Monitoring for cPanel Servers

This guide requires root user account in server. In some circumstances, ChkservD cPanel...

Assigning a Dedicated IP Address to a Subdomain using WHM

To assign a dedicated IP address to a subdomain, perform the following steps: Step 1: Add the...

View Server PHP Environment with phpinfo.php

The phpinfo() function outputs a huge amount of information about the system you're using, such...

How to Change Root Password Using SSH

This article explains the method of changing the root password on a Linux Server using SSH....

How to Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...