Have you noticed PHP-7.2 doesn’t support the mcrypt module anymore? Try installing it, and you’ll get an error that the package can’t be found or there is no installation candidate. For new users and students looking for help, the steps below should be a great place to start.
You may want to ask why the mcrypt module is no longer supported with PHP-7.2. Again, there may be a legitimate reason not to support it.
If you are running a PHP application that relies on the mcrypt module and wants to upgrade to PHP 7.2, then continue with the post below to learn how to install PHP 7.2 mcrypt module on Ubuntu 18.04 LTS servers and desktops.
To get started with installing the module, follow the steps below:
Before installing the mcrypt module, you must first install PHP-7.2 on Ubuntu. To do that, run the commands below:
sudo apt install php-7.2
After installing PHP above, continue below to install the required dependencies that will allow you to install the mcrypt module.
Install Required PHP Dependencies to Install Mcrypt
Now that PHP-7.2 is installed, run the commands below to install the required dependencies that will allow the mcrypt module to be installed on Ubuntu with PHP-7.2 support. To install the necessary packages, run the commands below.
sudo apt install php-dev libmcrypt-dev php-pear
After that, continue below to install mcrypt.
Now that PHP-7.2 and all its required dependencies to install mcrypt, run the commands below to install the PHP mcrypt module on Ubuntu using the pecl channel.
sudo pecl channel-update pecl.php.net sudo pecl install mcrypt-1.0.1
After running the commands above, you should see a message that reads PHP mcrypt module was successfully installed. And that you should include the mcrypt. So extension in the php.ini file.
Build process completed successfully Installing '/usr/lib/php/20170718/mcrypt.so' install ok: channel://pecl.php.net/mcrypt-1.0.1 configuration option "php_ini" is not set to php.ini location You should add "extension=mcrypt.so" to php.ini
Finally, run the commands below to open the PHP configuration file.
sudo nano /etc/php/7.2/cli/php.ini
Then add the line below into the file, just below [PHP], and save.
Save the file, and you’re done.
If you’re using an Apache2 HTTP server with PHP support, you may also want to add the mcrypt.so extension to the php.ini file below:
sudo nano /etc/php/7.2/apache2/php.ini
For Nginx, use this:
sudo nano /etc/php/7.2/fpm/php.ini
Now the mcrypt module should be installed and ready to use.
You may also like the post below: