5

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

Stefan Gehrig
  • 82,642
  • 24
  • 155
  • 189
John
  • 32,403
  • 80
  • 251
  • 422

9 Answers9

16

sudo apt-get install php5-mcrypt

works on ubuntu.

Ben
  • 2,661
  • 28
  • 31
6

Please see:

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

Stefan Gehrig
  • 82,642
  • 24
  • 155
  • 189
5

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!

user28763
  • 111
  • 1
  • 2
  • 4
  • Thanks for this answer, worked perfectly for me where other answers were giving me trouble. – zgc7009 Jan 11 '16 at 20:51
  • FINALLY ... someone who knows wtf they are talking about .. only took like 4 stack exchange threads to find this one .. THANK YOU!!! – Ryan Ellis May 17 '16 at 21:23
2

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.

JW.
  • 50,691
  • 36
  • 115
  • 143
0

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

Nico Prat
  • 686
  • 2
  • 6
  • 13
0

for php 5.3.X

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

like this : yum install php53-mcrypt and restart httpd

masoud2011
  • 896
  • 9
  • 10
0

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

tsalm
  • 1
0

After upgrading to php 5.4 running (Works)

sudo php5enmod mcrypt
sudo service apache2 restart
bummi
  • 27,123
  • 14
  • 62
  • 101
0

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

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

extension=mcrypt.so
Nebril
  • 3,153
  • 1
  • 33
  • 50