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/
Lastly I check with php -i | grep mcrypt
This is my output:
PHP 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
/etc/php/7.3/cli/conf.d/20-mcrypt.ini,
/etc/php/7.3/cli/conf.d/mcrypt.ini
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
I've found the solution to same problem.
In my case pecl install mcrypt-1.0.2
diplays something like
...
running: phpize
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
libmcrypt prefix? [autodetect] :
and problem persists also specifyng 20180731
in autodetect
.
After some checks I've figured out the problem: php cli runs php 7.3 so I thought that was well configured, but both phpize
and php-config
are linked to php 7.4!
So you just have to launch the follows:
sudo update-alternatives --set phpize /usr/bin/phpize7.3
sudo update-alternatives --set php /usr/bin/php7.3
sudo update-alternatives --set php-config /usr/bin/php-config7.3
and reistalled a newest version
pecl install mcrypt-1.0.2
That's all.
Note:
- eventually run
pecl uninstall mcrypt
before install the right version- if you don't find
phpize7.3
andphp-config7.3
, try installing viaapt-get install php7.3-dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With