How to enable mcrypt module for php7.2 in Ubuntu

This is an interface to the mcrypt library, which supports a wide variety of block algorithms such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes. Additionally, it supports RC6 and IDEA which are considered "non-free". CFB/OFB are 8bit by default.

This feature was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0. Also This extension has been moved to the PECL repository and is no longer bundled with PHP as of PHP 7.2.0.

So in-order to enable this extension, follow the steps below.

Step1: Login to the server via ssh.

Step2: Install dependencies.

#apt-get install php-dev libmcrypt-dev gcc make autoconf libc-dev pkg-config

Step3: Install mcrypt extension

#pecl install mcrypt-1.0.1

Just press enter when it asks about libmcrypt prefix

Step4: Enable mcrypt extension for apache

#echo "" | sudo tee -a /etc/php/7.2/apache2/conf.d/mcrypt.ini

Step5: Restart apache service

#service apache2 restart

That's all....

Leave a Reply