I have moved my magento 2 project from one vps server to another. So im currently setting up all the PHP modules. But there seem to be some problem with the mcrypt module.

This is what I have been doing.

$ sudo apt-get -y install gcc make autoconf libc-dev pkg-config
$ sudo apt-get -y install libmcrypt-de
$ sudo pecl install mcrypt-1.0.2
> libmcrypt prefix? [autodetect] :

Im adding "extension=mcrypt.so" to php.ini

Then I do

sudo bash -c "echo extension=/usr/lib/php/20190902/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20190902/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"

I followed these instruction: https://lukasmestan.com/install-mcrypt-extension-in-php7-2/

But when I check with php -i | grep mcrypt

I get this is my output:


HP Warning:  PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20180731
These options need to match
 in Unknown on line 0

I have checked both 20-mcrypt.ini and mcrypt.ini and they look exaclty the same. But my PHP seems to be compiled with the wrong module API. I google around but couldn't find anything specific on that. Any idéas? Thanks!

What I have been using

1 Answer 1


Mcrypt is deprecated since PHP 7.1.x and is removed now. I suggest replacing it with libsodium instead. Magento2 integrates without issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.