Tutorial To Install PHP Mcrypt Extension On Ubuntu 22.04/Debian [Updated]
PHP developers have removed it from the PHP package bundle because of no further development in Mcrypt. Some of the alternatives to Php Mcrypt are Sodium (available as of PHP 7.2.0) and OpenSSL.
But if you still want to use it then this tutorial is for you where we are going to show you the process to install PHP Mcrypt extensions on Ubuntu 22.04 LTS.
Install PHP Mcrypt Extension On Ubuntu 22.04/Debian [Updated]
At first, you need to update the installed packages in your Ubuntu 22.04 to avoid any future conflicts. Run the system update command to update the installed packages of the system and refresh the repo cache.
sudo apt update
Install Developer tools & Dependencies On Ubuntu 22.04
Now, you need to run the following command to install developer tools and dependencies on Ubuntu 22.01
sudo apt install gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php-dev
After installing developer tools and dependencies, run the following commands to update the channels that is responsible for Pear and Pecl to fetch packages-
pecl channel-update pecl.php.net pecl update-channels
Install Php Mcrypt extension on Ubuntu 22.04 or Debian
Now, its time to install PHP Mcrypt on Ubuntu 22.04 LTS. To do so, run the Pecl command in your Ubuntu to install Php Mcrypt extensions on Ubuntu 22.04 or Debian.
pecl install mcrypt
Enable “extension=mcrypt.so” via php.ini
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.
sudo nano /etc/php/*/apache2/php.ini
Save the file ctrl+X, type Y, and hit the Enter key.