What is the PHP Mcrypt extension?
PHP Mcrypt extension provides encryption facilities to web applications that need the functionality of modern algorithms such as AES. This extension works as an interface to the Mcrypt’s libmcrypt library which implements all the algorithms and modes found in it such as DES, TripleDES, Blowfish (default), SAFER-SK128, LOKI97, GOST, RC2, RC6, MARS, IDEA, RIJNDAEL-128 (AES), RIJNDAEL-192, TWOFISH, TEA, RC2, and more. However, PHP developers have removed it from the PHP package bundle since the launch of php7.2 because of no further development in Mcrypt, thus the extension also gets decrypted. Sodium (available as of PHP 7.2.0) and OpenSSL are now some alternatives to it.
However, the PHP Mcrypt extension has been moved to the PECL repository, thus if somebody wants, he or she can install it on Ubuntu 20.04 LTS using Pear. Here we will show how?
Go to Terminal, if you are using CLI server then you are already there. Simply run the system update command to refresh the repo cache and update the installed packages of the system.
sudo apt update
To install PHP Mcrypt on Ubuntu 20.04 or Debian, we have to install some tools needed to build packages from the source along with some developer dependency packages.
Finally, use the Pecl command to download and install php-mcrypt extension on your system
Once the installation is complete to activate the extension we have to add it in the php.ini file of the system. For that simply edit the php.ini file and under Dynamic extension, type:
extension=mcrypt.so beside other extensions, as shown in the screenshot.
Save the file ctrl+X, type Y, and hit the Enter key.
To ensure your web server has successfully recognized the enabled PHP mcrypt extension, reload the Apache server-