Newer PHP versions do not include PHP mcrypt library. The mcrypt module was part of PHP 5 till 7.1, in which it was deprecated and removed in 7.2. If you open the php.net documentation for mcrypt PHP functions you will see:
This function has been DEPRECATED as of PHP 7.1.0 and REMOVED as of PHP 7.2.0. Relying on this function is highly discouraged.
The mcrypt module is now in PHP PECL (repository for PHP Extensions) in https://pecl.php.net/package/mcrypt. As you can see in the description, this is a legacy module, which
Provides bindings for the unmaintained libmcrypt.
, so it is strongly recommended to replace it with OpenSSL (for example).
Still, if you need this legacy module – mcrypt and :
- use Linux distribution, which does not include the legacy module from https://pecl.php.net/package/mcrypt
- use PHP 7.2 and above
You may want to manually build the mcrypt module for your current installed PHP. Of course, the generic dependencies are:
- libmcrypt and its headers (if the Linux distribution) splits the binary and the headers
- GNU GCC
- PHP 7.2+
- download the latest mcrypt module source from https://pecl.php.net/package/mcrypt. For example, now it is https://pecl.php.net/get/mcrypt-1.0.2.tgz
mkdir /root/mcrypt-php-module-manual cd /root/mcrypt-php-module-manual wget https://pecl.php.net/get/mcrypt-1.0.2.tgz tar xzf mcrypt-1.0.2.tgz cd mcrypt-1.0.2 phpize aclocal libtoolize --force autoheader autoconf ./configure make make install
Do not use “make -j N” (“make -j 8”, for example), because it may fail to compile.
Keep on reading!