mcrypt安装问题

发布于 2024-10-14 18:20:19 字数 2093 浏览 5 评论 0原文

我已要求系统管理员在服务器上安装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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

ゞ记忆︶ㄣ 2024-10-21 18:20:19

尝试解决您的 mcrypt 问题:

mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
sudo php5enmod mcrypt
sudo service apache2 restart

这是 mcrypt.ini 文件位置的错误。

我有同样的错误,我做了一个 cp 而不是 mv 来确定,但它解决了问题。

对于 PHP 不工作,如果 phpmyadmin 工作(即使出现 mcrypt 错误),则意味着 PHP 正在工作(因为 phpmyadmin 使用 PHP)。但在你的例子中

<? echo $row['details']; ?>

change <? to <?php and try again?

Try this for your mcrypt problem:

mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
sudo php5enmod mcrypt
sudo service apache2 restart

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

<? echo $row['details']; ?>

change <? to <?php and try again?

猫卆 2024-10-21 18:20:19

在 Ubuntu 14.04 上只需要像 sudo 一样执行三个步骤:

apt-get install php5-mcrypt
php5enmod mcrypt
service apache2 restart

On Ubuntu 14.04 just need to do only three steps as sudo:

apt-get install php5-mcrypt
php5enmod mcrypt
service apache2 restart
汐鸠 2024-10-21 18:20:19

mcrypt 算法目录必须是包含算法的目录,而不是二进制文件。这意味着:

$modes = mcrypt_list_modes("/usr/local/bin/mcrypt");

应该是这个(假设安装的 mcrypt/usr/local/lib/libmcrypt):

$modes = mcrypt_list_modes("/usr/local/lib/libmcrypt");

如果 libmcrypt 所在的目录> 安装的不是上面那个,您必须更新您的 php.ini 设置。取自 php.ini

[mcrypt]

; Directory where to load mcrypt algorithms
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.algorithms_dir=

; Directory where to load mcrypt modes
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.modes_dir=

如果您有 shell 访问权限,您可以尝试此命令来查找 mcrypt 安装的 lib 目录:

whereis libmcrypt

或者...

whereis mcrypt

取决于您的设置。

The mcrypt algorithms directory must be a directory containing the algorithms, not a binary. This means that this:

$modes = mcrypt_list_modes("/usr/local/bin/mcrypt");

Should be this instead (assuming mcrypt is installed is /usr/local/lib/libmcrypt):

$modes = mcrypt_list_modes("/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:

[mcrypt]

; Directory where to load mcrypt algorithms
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.algorithms_dir=

; Directory where to load mcrypt modes
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.modes_dir=

If you have shell access, you can try this command to find the lib directory for your mcrypt installation:

whereis libmcrypt

or...

whereis mcrypt

Depending on your setup.

埋葬我深情 2024-10-21 18:20:19

我有完全相同的问题。

> mcrypt -v
Mcrypt v.0.9.9 (sparc-sun-solaris2.10)
Linked against libmcrypt v.2.5.8

> mcrypt --list-hash
Supported Hash Algorithms:
crc32
md5
sha1
haval256
ripemd160
tiger
gost
[...]

> php CryptoTest.php
PHP Warning:  mcrypt_list_modes(): No modes found in module dir in [...]

通过使用以下选项重新配置和重新编译 libmcrypt 解决了这个问题:

./configure --prefix=$YOUR_PATH/libmcrypt --enable-dynamic-loading --disable-posix-threads

然后在 php.ini 中:

mcrypt.algorithms_dir=<YOUR_PATH>/libmcrypt/lib/libmcrypt
mcrypt.modes_dir=<YOUR_PATH>/libmcrypt/lib/libmcrypt

I had exactly the same problem.

> mcrypt -v
Mcrypt v.0.9.9 (sparc-sun-solaris2.10)
Linked against libmcrypt v.2.5.8

> mcrypt --list-hash
Supported Hash Algorithms:
crc32
md5
sha1
haval256
ripemd160
tiger
gost
[...]

> php CryptoTest.php
PHP Warning:  mcrypt_list_modes(): No modes found in module dir in [...]

It was solved by reconfiguring and recompiling libmcrypt with these options:

./configure --prefix=$YOUR_PATH/libmcrypt --enable-dynamic-loading --disable-posix-threads

Then in your php.ini :

mcrypt.algorithms_dir=<YOUR_PATH>/libmcrypt/lib/libmcrypt
mcrypt.modes_dir=<YOUR_PATH>/libmcrypt/lib/libmcrypt
春庭雪 2024-10-21 18:20:19

如何在 MAC OSX 上安装 mcrypt:

您好,已在 Mac OSX El Capitan 上测试并运行:

1. 下载 mcrypt:http://www.viames.it/download/elcapitan/mcrypt.so

2. 将其放入:

/usr/lib/php/extensions/mcrypt

3. 修改“php.ini”

/etc/php.ini

并添加以下行:

extension = /usr/lib/php/extensions/mcrypt.so

4. 使用以下命令检查“mcrypt”是否已加载:

php-m

php -m 控制台结果

5. 创建一个包含以下内容的 'phpinfo.php'

<?php echo phpinfo(); ?>

:查看是否列出了 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:

/usr/lib/php/extensions/mcrypt

3. Modify your 'php.ini'

/etc/php.ini

and add the following line:

extension = /usr/lib/php/extensions/mcrypt.so

4. Check if 'mcrypt' is loaded with the following command:

php -m

php -m console result

5. Create a 'phpinfo.php' with content:

<?php echo phpinfo(); ?>

and see if mcrypt is listed:

phpinfo() shows now mcrypt to be loaded

Yes, I know I'm a gangsta.

乜一 2024-10-21 18:20:19

架构: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 版本:

php-mcrypt.x86_64                    5.3.3-5.el6                                  @epel

但是,5.4 已在 /opt/rh/php54

仅仅复制 5.3 模块和配置文件是行不通的。该模块初始化失败,这就是为什么它没有出现在 phpinfo() 中,这可以通过检查。

/opt/rh/php54/root/usr/bin/php  -v

对我有用的解决方案是下载 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)

wget ftp://fr2.rpmfind.net/linux/remi/fedora/25/remi/x86_64/php54-php-mcrypt-5.4.45-12.fc25.remi.x86_64.rpm

使用 RPM2CPIO 提取文件:

rpm2cpio php54-php-mcrypt-5.4.45-12.fc25.remi.x86_64.rpm |cpio -idmv
./opt/remi/php54/root/etc/php.d/mcrypt.ini
./opt/remi/php54/root/usr/lib64/php/modules/mcrypt.so
98 blocks

并复制到 chroot 文件夹

cp ./opt/remi/php54/root/etc/php.d/mcrypt.ini /opt/rh/php54/root/etc/php.d/mcrypt.ini
cp ./opt/remi/php54/root/usr/lib64/php/modules/mcrypt.so /opt/rh/php54/root/usr/lib64/php/modules/

要检查:

/opt/rh/php54/root/usr/bin/php  -v

并且:

<html>
<body>
<?php
phpinfo();
?>
</body>
</html>

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 for 5.3 in normal root:

php-mcrypt.x86_64                    5.3.3-5.el6                                  @epel

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

/opt/rh/php54/root/usr/bin/php  -v

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)

wget ftp://fr2.rpmfind.net/linux/remi/fedora/25/remi/x86_64/php54-php-mcrypt-5.4.45-12.fc25.remi.x86_64.rpm

extract the files with RPM2CPIO:

rpm2cpio php54-php-mcrypt-5.4.45-12.fc25.remi.x86_64.rpm |cpio -idmv
./opt/remi/php54/root/etc/php.d/mcrypt.ini
./opt/remi/php54/root/usr/lib64/php/modules/mcrypt.so
98 blocks

And copy to the chroot folder

cp ./opt/remi/php54/root/etc/php.d/mcrypt.ini /opt/rh/php54/root/etc/php.d/mcrypt.ini
cp ./opt/remi/php54/root/usr/lib64/php/modules/mcrypt.so /opt/rh/php54/root/usr/lib64/php/modules/

To check:

/opt/rh/php54/root/usr/bin/php  -v

And also:

<html>
<body>
<?php
phpinfo();
?>
</body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文