How to enable php-mcrypt extension in cpanel

  1. cPanel & WHM Documentation
  2. EasyApache4
  3. PHP
  4. PHP Module: Mcrypt


Last modified: July 8, 2022

Overview

The mcrypt PHP module provides an interface to the mcrypt library and supports encryption. The cPanel-provided EasyApache 4 profiles include the mcrypt PHP module by default.

Compatibility

As of PHP 7.2, this module is only available through the PHP Extension Community Library (PECL).

Requirements

This module depends on the mcrypt library, which EasyApache 4 installs to the /opt/cpanel/libmcrypt directory when you install the mcrypt module.

Installation steps

In the interface

To install or uninstall the mcrypt PHP module, use WHM’s EasyApache 4 interface (WHM >> Home >> Software >> EasyApache 4).

On the command line

To install the mcrypt PHP module, perform the following steps:

  1. On the command line as the root user, copy the files from the /opt/cpanel/libmcrypt/lib64/ directory to the /opt/cpanel/libmcrypt/lib/ directory with the following command:

    rsync -avH /opt/cpanel/libmcrypt/lib64/ /opt/cpanel/libmcrypt/lib/

  2. Install the mcrypt module with the following command:

    ea-php72-pecl install mcrypt-1.0.2

  3. When the system prompts for the libmcrypt prefix, enter the following directory path:

Additional Documentation


  • MultiPHP INI Editor for WHM
  • MultiPHP Manager for cPanel
  • The clean_user_php_sessions Script
  • The php_fpm_config Script
  • The rebuild_phpconf Script
  • The cPanel Glossary

How to enable php-mcrypt extension in cpanel

cPanel, WebHost Manager and WHM are registered trademarks of cPanel, L.L.C. for providing its computer software that facilitates the management and configuration of internet web servers.

 

Do the below steps to install mcrypt PHP extension on CentOS and RHEL servers.

1. Log into your Linux server via SSH as ‘root’ user

2. Install EPEL repository by running “yum install epel-release”

Edit epel.repo and change enabled=1

3. Check yum.conf and remove php* from yum exclude list (if you have added php in yum exclude list)

4. Run the command “yum -y install php-mcrypt” to install PHP mycrypt extension

5. Restart apache service using command : service httpd restart

Now Type the command “php -m | grep mcrypt” to check whether it is installed correctly. You can also check by creating a phpinfo page under the website.

[root@server ~]# php -m | grep mcrypt
mcrypt


How to Install mcrypt extension on cPanel Servers with Easyapache 4

On easyapache 4 servers you can use yum to install PHP extensions. You must have server root login details to install this PHP extension.

1. Log into cPanel server via SSH as root

2. Type the command “[root@server ~]# rpm -qa | grep mcrypt” to check whether Mcrypt is installed

[root@server ~]# rpm -qa | grep mcrypt
[root@server ~]#

The extension is not installed on the above server

3. Run the command “yum install ea-phpXX-php-mcrypt” to install Mcrypt

XX in the above command should be replaced with the correct PHP version.

Command to install Mcrypt for PHP 5.4 : yum install ea-php54-php-mcrypt
Command to install Mcrypt for PHP 5.5 : yum install ea-php55-php-mcrypt
Command to install Mcrypt for PHP 5.6 : yum install ea-php56-php-mcrypt
Command to install Mcrypt for PHP 7.0 : yum install ea-php70-php-mcrypt
Command to install Mcrypt for PHP 7.1 : yum install ea-php71-php-mcrypt

4. Type the below command to verify it is installed correctly

[root@server ~]# php -m | grep mcrypt
mcrypt

[root@server ~]# rpm -qa | grep mcrypt
ea-php56-php-mcrypt-5.6.30-1.1.3.cpanel.x86_64
ea-php71-php-mcrypt-7.1.1-1.1.2.cpanel.x86_64
ea-php55-php-mcrypt-5.5.38-8.8.10.cpanel.x86_64
ea-php70-php-mcrypt-7.0.15-1.1.3.cpanel.x86_64
ea-php54-php-mcrypt-5.4.45-26.26.10.cpanel.x86_64
 


How to Install mcrypt extension on cPanel Servers with Easyapache 3

On easyapache 3 servers you can install mcrypt extension either through server backend or through WHM

(I) Install Mcrypt through WHM :

1. Login to WHM using server root password

Link to access WHM : https://YourServerIP:2087

2. Search for “EasyApache 3” in WHM search bar on left

3. Click on “EasyApache 3” under “Software”

WHM Home » Software » EasyApache 3

4. Under “Exhaustive Options List” you must tick “Mcrypt”

 

How to enable php-mcrypt extension in cpanel

  5. Click on “Save and Build”

  (II)Enable mcrypt from server backend

1. Login to server via SSH as ‘root’

2. Run easyapache in screen

Command : screen -S easyapache

Easyapache might get stopped if your session gets disconnected. All the sites will be down if easyapache gets interrupted.

3. Run the command “/scripts/easyapache” to start easyapache

4. Under “Exhaustive Options List” you must select “Mcrypt”

 

How to enable php-mcrypt extension in cpanel

  5. Select “Save and build”

Create a phpinfo page under your domain to check whether “Mcrypt” extension is enabled.

How do I enable mcrypt PHP extension in cPanel?

Procedure.
Install the libmcrypt extension: yum install libmcrypt..
Install the EPEL repository: yum install epel-release..
Install the libmcrypt-devel package from the EPEL repository: yum install libmcrypt-devel..
Install mcrypt via PECL: /opt/cpanel/ea-php72/root/usr/bin/pecl install mcrypt..

How do I know if mcrypt is enabled?

You can also achieve this same screen by viewing a php file that has: phpinfo(); somewhere in the code. In this screen, simply search for the string "mcrypt support". If installed, you will see a box that says "enabled".

What is mcrypt PHP extension?

The mcrypt extension is an interface to the mcrypt cryptography library. This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+. The mcrypt extension is included in PHP 5.4 through PHP 7.1.

How do you solve the Encrypt library requires the mcrypt extension?

with php 7 and above mcrypt need not to be loaded manually so both of the solution will work..
$this->load->library('encrypt'); change to $this->load->library('encrypt');.
Just remove encrypt from autoload. $autoload['libraries'] = array('database','session','upload','form_validation','encrypt','pagination');.