Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with mcrypt installation

Tags:

php

mcrypt

centos

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.

like image 505
Kide Avatar asked Jan 26 '11 20:01

Kide


People also ask

How do I install mcrypt extension?

You can install Mcrypt from the PHP Source Tree as a module if you choose. Enable the module by adding: 'extension=mcrypt.so' to PHP. ini. Done!

Is mcrypt deprecated?

The mcrypt extension has been abandonware for nearly a decade now, and was also fairly complex to use. It has therefore been deprecated in favour of OpenSSL, where it will be removed from the core and into PECL in PHP 7.2.

How do I know if mcrypt is installed?

You can also achieve this same screen by viewing a php file that has: phpinfo(); somewhere in the code. In this screen, simply search for the string "mcrypt support". If installed, you will see a box that says "enabled".


1 Answers

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?
like image 129
Akarsh Satija Avatar answered Sep 26 '22 10:09

Akarsh Satija