How to install php-mcrypt module on CentOS 8 with PHP 7.4

A recent migration to a CentOS 8 server from CentOS 6 did not go as smoothly as planned. As well as imagined, everything was upgraded along the way.  PHP 5.x to PHP 7.4 for example. One web application had been running smoothly on PHP 5.x for many years. However, after the migration, complained that php-mcrypt needed to be installed. The php-mcrypt module has been deprecated since PHP 7.1. I didn’t want to go through the path of uninstalling the PHP 7.4 in favor of the REMI repos; instead compile the module.

After considerable searching, I found a process that worked flawlessly.

dnf install -y epel-release
yum install --enablerepo=epel -y gcc libmcrypt-devel make
pecl install mcrypt-1.0.3
echo 'extension=mcrypt.so' > /etc/php.d/20-mcrypt.ini
systemctl reload httpd php-fpm

Source

  • https://support.plesk.com/hc/en-us/articles/213925125-How-to-install-the-php-mcrypt-module-on-a-Plesk-server
  • https://pecl.php.net/package/mcrypt