Introduction
The mcrypt extension was once a popular PHP library used for encryption and decryption. However, starting with PHP 7.2 and above, it was removed from the core PHP distribution and deprecated due to security concerns. Because of this, it is no longer installed by default in cPanel servers via EasyApache. But if you still need it for legacy applications, it’s possible to install it manually using PECL and enable it with a few extra steps to Enable mcrypt Extension in PHP 7.2 cPanel.
Prerequisites
Before you begin, make sure:
- You have root SSH access to your server.
- You know your target PHP version (e.g., PHP 7.2, 7.4, 8.0).
- Your server uses php-fpm and you can restart it.
Your system uses one of the supported Linux distributions (CentOS, AlmaLinux, CloudLinux, Ubuntu, etc.).
Steps
1. Install Required Libraries
First install the libmcrypt library and development packages required to compile the extension:
For RedHat-based systems (AlmaLinux, CentOS, CloudLinux):
yum install libmcrypt libmcrypt-devel epel-release
For Ubuntu:
apt install libmcrypt libmcrypt-dev
These libraries provide the core mcrypt functions and headers needed to build the extension.
2. Install mcrypt via PECL
PECL is a repository of PHP extensions. Use the PECL tool included with your chosen PHP version:
/opt/cpanel/ea-php##/root/usr/bin/pecl install mcrypt
Replace ## with your actual PHP version number, e.g., ea-php72 for PHP 7.2.
During installation, PECL may ask for a “libmcrypt prefix”.
3. Edit the pecl.ini File
After installation, you need to tell PHP to load the extension.For that:
echo "extension=mcrypt.so" > /opt/cpanel/ea-php##/root/etc/php.d/zzzzzzz-pecl.ini
Here, zzzzzzz-pecl.ini is just a descriptive filename — it helps you identify the custom ini file later if needed. This line tells PHP to load mcrypt.so when PHP starts.
4. Restart PHP-FPM
For the changes to take effect, you must restart PHP-FPM:
systemctl restart ea-php##-php-fpm
Again, replace ## with your PHP version (e.g., 72, 74). This ensures that PHP reloads all extensions, including the newly installed mcrypt. Restarting php_fpm is crucial — without it the extension won’t be recognized.
Conclusion
Installing the mcrypt extension on PHP 7.2 and above with cPanel is possible, but it’s no longer supported directly by cPanel or EasyApache. To Enable mcrypt Extension in PHP 7.2 cPanel, you must manually install the required libraries, use PECL to install the mcrypt module, create a custom configuration file (such as zzzzzzz-pecl.ini) to load the extension, and then restart php-fpm so the changes take effect.
Although this approach allows legacy applications to continue functioning, it requires proper server configuration and careful handling of dependencies. Tasks like these are often handled through professional Server Management Services that specialize in maintaining and optimizing hosting environments. With expert cPanel Server Management, administrators can safely configure PHP modules, manage extensions, and ensure that the server runs smoothly without affecting other services.
However, it’s important to remember that mcrypt has been deprecated due to security concerns. While enabling it can help support older applications, modern software should move toward more secure encryption libraries such as OpenSSL or libsodium to ensure better security and long-term compatibility.