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
    /opt/cpanel/ea-php83/root/usr/bin/pecl
    /opt/cpanel/ea-php84/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:
    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
    printf "\n" | /opt/cpanel/ea-php84/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.

Launch 100% SSD VPS from $2.49/mo!

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

Related Articles

How to Create Sudo User on CentOS

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

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...

Set Server Time Zones with Timedatectl

This article provides a guide to setting the server time and server time zone settings using...

htaccess RewriteRule Examples

Here are some useful mod_rewrite RewriteRule redirect examples that you can use in your .htaccess...

Using htaccess File to Block IPs

If your webserver is Apache, you may block access to your website from specific IP addresses...