Php – Howto make MCrypt and PHP work together on CentOS

centosmcryptPHP

I've installed mcrypt on CentOS ( via yum ), but when I try to do a dl() call in A), I get the message in B).

  • A) dl( mcrypt.so ) or die('The Mcrypt
    module could not be loaded ['.
    $prefix . 'mcrypt.' .
    PHP_SHLIB_SUFFIX .']');
  • B) The
    Mcrypt module could not be loaded [
    mcrypt.so ]

Now, I know that yum has installed mcrypt, but I don't know the location it has put it in. Can I find that out? More importantly, how can I get the latest installed mcrypt working with my PHP system. Many threads suggest you recompile PHP ( ex: http://forums.theplanet.com/index.php?showtopic=26527 ), but I don't know how to do this with CentOS. I've also played with my library paths to no avail. Any help would be greatly appreciated.

Setup

  • CentOS: Linux localhost.localdomain
    2.6.18-128.1.6.el5 #1 SMP Wed Apr 1 09:10:25 EDT 2009 x86_64 x86_64
    x86_64 GNU/Linux
  • mcrypt: mcrypt-2.6.8-1.el5.x86_64
  • PHP: php-5.1.6-23.2.el5_3.x86_64

Thanks
Tim

Best Answer

Login as a root or Super User to the server and add the below commands


yum install php53-devel
yum install libmcrypt-devel
yum install gcc
wget http://museum.php.net/php5/php-5.3.3.tar.bz2
tar xvjf php-5.3.3.tar.bz2
cd php-5.3.3/ext/mcrypt/
phpize
aclocal
./configure
make
make install
echo "extension=mcrypt.so" > /etc/php.d/mcrypt.ini
service httpd restart

Reference Install PHP 5.3 mcrypt extension on Centos 5.6