升级 php 7.2 后,提示 call to undefined function mcrypt_module_open() ;mcrypt 扩展从 php 7.1.0 开始废弃;自 php 7.2.0 起,会移到 pecl。还好,安装过程不复杂,用root用户运行以下命令。
- pecl
apt-get install php-pecl
2.相关扩展
apt-get install libmcrypt-dev libreadline-dev
3.mcrypt
pecl install mcrypt-1.0.1
执行完会看到以下信息。
...
Build process completed successfully
Installing ‘/usr/lib/php/20170718/mcrypt.so‘ ----> this is our path to mcrypt extension lib
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
4.mcrypt.so扩展名添加到php.ini中
在ln -s软连接到cli和 (fpm or apache2 )
/etc/php/7.2/mods-available (php.ini)
/etc/php/7.2/cli/conf.d/ (cli)
/etc/php/7.2/fpm/conf.d/ (fpm)
/etc/php/7.2/apache2/conf.d/ (apache2)
5.重启php-fpm,再次查看已经安装成功
php -i | grep mcrypt
php -m | grep mcrypt
原文地址:http://blog.51cto.com/jinchen/2141477