PHP 的 mcrypt_decrypt() 需要什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/639680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:20:55  来源:igfitidea点击:

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

phpmcrypt

提问by John

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

我有一个使用 mcrypt_decrypt() 函数的脚本,但出现以下错误

Fatal error: Call to undefined function mcrypt_decrypt()

致命错误:调用未定义的函数 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

谢谢

回答by Ben

sudo apt-get install php5-mcrypt

须藤 apt-get 安装 php5-mcrypt

works on ubuntu.

在 ubuntu 上工作。

回答by Stefan Gehrig

Please see:

请参见:

You need to compile your PHP with --with-mcrypt[=DIR]and have libmcrypt Version 2.5.6 or greater on your machine.

您需要使用--with-mcrypt[=DIR]libmcrypt 2.5.6 或更高版本来编译 PHP并在您的机器上安装。

回答by user28763

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

使用 php5-fpm 配置 php5-mcrypt (Ubuntu 14.04)

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

我将假设您已经安装并运行了 nginx 和 php-fpm。

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

php5-mcrypt 应该已经安装了(它与 php5-fpm 捆绑在一起)。为了安全起见,apt-get install php5-mcrypt

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

创建指向 mods-avaliable 的符号链接,ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini

Enable it. php5enmod mcrypt

启用它。php5enmod mcrypt

Restart php-fpm, service php5-fpm restart

重启php-fpm,服务php5-fpm重启

Restart nginx, service nginx restart

重启nginx,服务nginx重启

Done!

完毕!

回答by JW.

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.

您需要使用 --with-mcrypt[=DIR] 参数编译 PHP 才能启用此扩展。DIR 是 mcrypt 安装目录。确保使用选项 --disable-posix-threads 编译 libmcrypt。

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

通常,如果 PHP 说一个函数未定义,则意味着您需要在某个库中进行编译。

回答by Nebril

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

我上面的不行,你可以试试这个:

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

在 /etc/php5/conf.d 中创建带有内容的 mcrypt.ini 文件

extension=mcrypt.so

回答by Nico Prat

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

我通过http://php-osx.liip.ch/将 PHP 升级到 5.4并且它起作用了。

回答by masoud2011

for php 5.3.X

对于 php 5.3.X

depends on availability of yum mcrypt package , you could use yum packeages

取决于 yum mcrypt 包的可用性,您可以使用 yum 包

like this : yum install php53-mcrypt and restart httpd

像这样:yum 安装 php53-mcrypt 并重新启动 httpd

回答by tsalm

And be carefull about the folder in the phpinfo page : "Scan this dir for additional .ini files" and the next : "Additional .ini files parsed ".

并注意 phpinfo 页面中的文件夹:“扫描此目录以获取其他 .ini 文件”和下一个:“已解析的其他 .ini 文件”。

回答by Danny Mu?oz

After upgrading to php 5.4 running (Works)

升级到 php 5.4 后运行 (Works)

sudo php5enmod mcrypt
sudo service apache2 restart