PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mcrypt.so' - libmcrypt.so.4: cannot open shared object file: No such file or directory in Unknown on line 0
Posted: 7 May 2012, 23:34pm - Monday

I created some script in php, encrypting and decrypting my emails. but when I ran the script, got some issues. When I traced it, the php-mcrypt library is missing. I am using CentOS 6.2 at 64bit architecture. Some says I will move the libmcrypt.so.4 and  libmcrypt.so.4.4.8 from /usr/lib to usr/lib64 and /usr/lib/php/mcrypt.so to /usr/lib64/php/mcrypt.so but when I check the file, its not there. The files aren't there at the installed directory. to check this issues, cast php -v;

[root@mail lib64]# php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mcrypt.so' - libmcrypt.so.4: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.3.3 (cli) (built: Feb  2 2012 23:47:49)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.10, Copyright (c) 2002-2011, by ionCube Ltd.
If there's PHP Warning, then that means there are missing files... if more warnings, probably there's a problem during installation of your php. But in this guide, I will only discuss how to fix the php-mcrypt issues. First download the lacking files, which are;
  1. libmcrypt-2.5.8-4.el5.centos.x86_64.rpm
  2. php-mcrypt-5.3.3-1.el6.x86_64.rpm
You can download those files at rpmfind.net or rpm.pbone.net. Then extract the files inside the rpm pack by using the command rpm2cpio.
[root@mail ~]# rpm2cpio libmcrypt-2.5.8-4.el5.centos.x86_64.rpm | cpio -idmv
[root@mail ~]# rpm2cpio php-mcrypt-5.3.3-1.el6.x86_64.rpm | cpio -idmv
Then move the files that you just extracted to /usr/lib64 and after moving the files, restart httpd and cast again the php -v.
[root@mail ~]# php -v
PHP 5.3.3 (cli) (built: Feb  2 2012 23:47:49)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.10, Copyright (c) 2002-2011, by ionCube Ltd.
[root@mail ~]#
This is the output you should get, no PHP Warnings and php-mcrypt should be working fine. That's it! Happy solving!