mcrypt安装问题
我已要求系统管理员在服务器上安装mcrypt,他们说一切正常。但是当我运行我的简单脚本时,我得到了这个。
警告:mcrypt_get_iv_size() [function.mcrypt-get-iv-size]:模块初始化失败
它来自这一行:
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB);
现在,从这段代码中:
$algorithms = mcrypt_list_algorithms("/usr/local/bin/mcrypt");
foreach ($algorithms as $cipher) {
echo "$cipher<br />\n";
}
我得到:
警告:mcrypt_list_algorithms() [function.mcrypt-list-algorithms]:在模块目录中找不到算法
当我运行此命令时:
$modes = mcrypt_list_modes("/usr/local/bin/mcrypt");
foreach ($modes as $mode) {
echo "$mode <br />\n";
}
我得到:
警告:mcrypt_list_modes() [function.mcrypt-list-modes]:在模块目录中找不到模式
但是,运行此命令此命令
which mcrypt; mcrypt -v
会生成:
/usr/local/bin/mcrypt
Mcrypt v.0.9.9 (x86_64-unknown-linux-gnu)
Linked against libmcrypt v.2.5.7
Copyright (C) 1998-2002 Nikos Mavroyanopoulos ([email protected])
mcrypt 安装/配置正确吗?
更新:
我这样做了:
whereis libmcrypt
...并得到了结果:
libmcrypt: /usr/local/lib/libmcrypt /usr/local/lib/libmcrypt.so /usr/local/lib/libmcrypt.la
我也更改
$modes = mcrypt_list_modes("/usr/local/bin/mcrypt");
为:...
$modes = mcrypt_list_modes("/usr/local/lib/libmcrypt");
$algorithms = mcrypt_list_algorithms("/usr/local/lib/libmcrypt");
按照建议,但仍然收到错误:
警告:mcrypt_list_modes() [function.mcrypt-list-modes]:在模块目录中找不到模式
然后我进入 CPanel 中的文件管理器到 /usr/local/lib/libmcrypt
。该目录存在,但其中没有文件...
谢谢。
I've asked the system admins to install mcrypt on the server, and they say everything is OK. But when I run my simple script I get this.
Warning: mcrypt_get_iv_size() [function.mcrypt-get-iv-size]: Module initialization failed
It's coming from this line:
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB);
Now, from this code:
$algorithms = mcrypt_list_algorithms("/usr/local/bin/mcrypt");
foreach ($algorithms as $cipher) {
echo "$cipher<br />\n";
}
I get:
Warning: mcrypt_list_algorithms() [function.mcrypt-list-algorithms]: No algorithms found in module dir
When I run this:
$modes = mcrypt_list_modes("/usr/local/bin/mcrypt");
foreach ($modes as $mode) {
echo "$mode <br />\n";
}
I get:
Warning: mcrypt_list_modes() [function.mcrypt-list-modes]: No modes found in module dir
However, running this command this command
which mcrypt; mcrypt -v
Produces:
/usr/local/bin/mcrypt
Mcrypt v.0.9.9 (x86_64-unknown-linux-gnu)
Linked against libmcrypt v.2.5.7
Copyright (C) 1998-2002 Nikos Mavroyanopoulos ([email protected])
Is mcrypt installed/configured correctly?
UPDATE:
I did this:
whereis libmcrypt
...and got the result:
libmcrypt: /usr/local/lib/libmcrypt /usr/local/lib/libmcrypt.so /usr/local/lib/libmcrypt.la
I've also changed:
$modes = mcrypt_list_modes("/usr/local/bin/mcrypt");
to...
$modes = mcrypt_list_modes("/usr/local/lib/libmcrypt");
$algorithms = mcrypt_list_algorithms("/usr/local/lib/libmcrypt");
As recommended, but still get the error:
Warning: mcrypt_list_modes() [function.mcrypt-list-modes]: No modes found in module dir in
Then I went into the file manager in my CPanel to /usr/local/lib/libmcrypt
. The directory exists but it has no files in it...
Here is the print screen of the file manager.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
尝试解决您的 mcrypt 问题:
这是 mcrypt.ini 文件位置的错误。
我有同样的错误,我做了一个 cp 而不是 mv 来确定,但它解决了问题。
对于 PHP 不工作,如果 phpmyadmin 工作(即使出现 mcrypt 错误),则意味着 PHP 正在工作(因为 phpmyadmin 使用 PHP)。但在你的例子中
change
<?
to<?php
and try again?Try this for your mcrypt problem:
It's a bug with the location of the mcrypt.ini file.
I had the same bug, I did a cp instead of a mv to be sure but it solved the problem.
For PHP not working, if you get phpmyadmin working (even with the mcrypt error), it means PHP is working (because phpmyadmin uses PHP). But in your example
change
<?
to<?php
and try again?在 Ubuntu 14.04 上只需要像 sudo 一样执行三个步骤:
On Ubuntu 14.04 just need to do only three steps as sudo:
mcrypt 算法目录必须是包含算法的目录,而不是二进制文件。这意味着:
应该是这个(假设安装的 mcrypt 是
/usr/local/lib/libmcrypt
):如果
libmcrypt
所在的目录> 安装的不是上面那个,您必须更新您的 php.ini 设置。取自 php.ini:如果您有 shell 访问权限,您可以尝试此命令来查找 mcrypt 安装的 lib 目录:
或者...
取决于您的设置。
The mcrypt algorithms directory must be a directory containing the algorithms, not a binary. This means that this:
Should be this instead (assuming mcrypt is installed is
/usr/local/lib/libmcrypt
):If the directory where
libmcrypt
is installed is not that one above, you have to update your php.ini setting. Taken from php.ini:If you have shell access, you can try this command to find the lib directory for your mcrypt installation:
or...
Depending on your setup.
我有完全相同的问题。
通过使用以下选项重新配置和重新编译 libmcrypt 解决了这个问题:
然后在 php.ini 中:
I had exactly the same problem.
It was solved by reconfiguring and recompiling libmcrypt with these options:
Then in your php.ini :
如何在 MAC OSX 上安装 mcrypt:
您好,已在 Mac OSX El Capitan 上测试并运行:
1. 下载 mcrypt:http://www.viames.it/download/elcapitan/mcrypt.so
2. 将其放入:
3. 修改“php.ini”
并添加以下行:
4. 使用以下命令检查“mcrypt”是否已加载:
php -m 控制台结果
5. 创建一个包含以下内容的 'phpinfo.php'
:查看是否列出了 mcrypt:
phpinfo() 显示现在要加载 mcrypt
是的,我知道我'我是一个黑帮。
How to install mcrypt on MAC OSX:
Hello, tested and working on Mac OSX El Capitan:
1. Download mcrypt: http://www.viames.it/download/elcapitan/mcrypt.so
2. Place it in:
3. Modify your 'php.ini'
and add the following line:
4. Check if 'mcrypt' is loaded with the following command:
php -m console result
5. Create a 'phpinfo.php' with content:
and see if mcrypt is listed:
phpinfo() shows now mcrypt to be loaded
Yes, I know I'm a gangsta.
架构:Centos 6 / Apache 2.2 / 双 PHP 安装(5.3 和 5.4)
更新:此解决方案解释了如何从 Centos 6 上的 Remi 的 RPM 手动安装 PHP 5.4 模块 mcrypt,但此 RPM 需要 glibc -2.14+,所以如果你的 glibc 比这个旧,这还不足以让它工作。
在我的配置中,
Yum install php-mcrypt*
显示为在普通 root 中安装了5.3
版本:但是,5.4 已在
/opt/rh/php54
仅仅复制 5.3 模块和配置文件是行不通的。该模块初始化失败,这就是为什么它没有出现在 phpinfo() 中,这可以通过检查。
对我有用的解决方案是下载 Remi 的 RPM(尽管通常通过添加他的 Yum 存储库更容易安装它,如评论)(https://www.rpmfind.net/linux/RPM/remi/fedora/25/x86_64/php54-php-mcrypt-5.4.45-12.fc25.remi.x86_64.html)
使用 RPM2CPIO 提取文件:
并复制到 chroot 文件夹
要检查:
并且:
Architecture: Centos 6 / Apache 2.2 / Dual PHP installation (5.3 and 5.4)
UPDATE: This solution explains how to install the module mcrypt with PHP 5.4 manually from Remi's RPM on Centos 6, but this RPM requires glibc-2.14+, so this only is not enough to make it work, if your glibc is older than that.
In my configuration,
Yum install php-mcrypt*
showed as installed the version for5.3
in normal root:However, 5.4 is chrooted in
/opt/rh/php54
Simply copying the 5.3 modules and config files does not work. The module fails initialization, that's why it does not appear in phpinfo(), this can be checked with
The solution that worked for me is to download the Remi's RPM (although it's normally easier to install it by adding his Yum repository as discussed in the Comments) (https://www.rpmfind.net/linux/RPM/remi/fedora/25/x86_64/php54-php-mcrypt-5.4.45-12.fc25.remi.x86_64.html)
extract the files with RPM2CPIO:
And copy to the chroot folder
To check:
And also: