What's needed for PHP's mcrypt_decrypt()?

2019-06-22 09:04发布

I have a script that uses mcrypt_decrypt() function, but I get the following error

Fatal error: Call to undefined function mcrypt_decrypt()

What modules/libraries do I need to include to use this function? Or is there another reason I'm getting the error?

Thanks

标签: php mcrypt
9条回答
再贱就再见
2楼-- · 2019-06-22 09:26

Configure php5-mcrypt with php5-fpm (Ubuntu 14.04)

I’m going to assume you already have nginx and php-fpm installed and running.

php5-mcrypt should be installed already (it comes bundled with php5-fpm). Just for safety, apt-get install php5-mcrypt

Create symlink to mods-avaliable, ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini

Enable it. php5enmod mcrypt

Restart php-fpm, service php5-fpm restart

Restart nginx, service nginx restart

Done!

查看更多
叼着烟拽天下
3楼-- · 2019-06-22 09:26

I upgraded PHP to 5.4 via http://php-osx.liip.ch/ and it worked.

查看更多
Juvenile、少年°
4楼-- · 2019-06-22 09:30

From the manual:

You need to compile PHP with the --with-mcrypt[=DIR] parameter to enable this extension. DIR is the mcrypt install directory. Make sure you compile libmcrypt with the option --disable-posix-threads.

Generally if PHP says a function is undefined, it means you need to compile in some library.

查看更多
看我几分像从前
5楼-- · 2019-06-22 09:35

sudo apt-get install php5-mcrypt

works on ubuntu.

查看更多
smile是对你的礼貌
6楼-- · 2019-06-22 09:39

After upgrading to php 5.4 running (Works)

sudo php5enmod mcrypt
sudo service apache2 restart
查看更多
再贱就再见
7楼-- · 2019-06-22 09:43

I above doesn't work, you can try this:

create mcrypt.ini file in /etc/php5/conf.d with content

extension=mcrypt.so
查看更多
登录 后发表回答