Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

mcrypt

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

like image 993
John Avatar asked Mar 12 '09 17:03

John


4 Answers

Please see:

  • Mcrypt Requirements
  • Mcrypt Installation

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

like image 37
Stefan Gehrig Avatar answered Oct 02 '22 00:10

Stefan Gehrig


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!

like image 23
user28763 Avatar answered Oct 02 '22 00:10

user28763


sudo apt-get install php5-mcrypt

works on ubuntu.

like image 191
Ben Avatar answered Oct 02 '22 00:10

Ben


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.

like image 45
JW. Avatar answered Oct 01 '22 23:10

JW.