How to get MCrypt and PHP to work with CentOS
I installed mcrypt on CentOS (via yum), but when I try to make a dl () call in A) I get a message in B).
- A) dl (mcrypt.so) or die ('The Mcrypt module could not be loaded ['. $ Prefix. 'Mcrypt., PHP_SHLIB_SUFFIX.'] ');
- B) Failed to load module Mcrypt [mcrypt.so]
Now I know that yum installed mcrypt, but I don't know where it put it in. May I find out? More importantly, how can I get the latest mcrypt installed working with my PHP system. Many threads suggest you recompile PHP (eg: http://forums.theplanet.com/index.php?showtopic=26527 ), but I don't know how to do this with CentOS. I have also played around with my library paths to no avail. Any help would be greatly appreciated.
Setting up
- 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
Log in as root or Super User to the server and add the following 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
Link Install PHP 5.3 mcrypt extension on Centos 5.6
Ok, I'm going to suggest some reasons why you can't use the package provided by the CentOS distributors (see here for an example.) I don't know CentOS, but I can give you a rough outline of the steps that are most likely to lead to successful building and installing the mcrypt module for PHP.
-
Get a copy of the PHP source that matches your compiled version of the distribution (CentOS may have a package for this)
-
Install PHP pacakges (maybe something like "php5-dev") as well as all dependencies to build PHP for your distribution (on Debian based systems this is done via
apt-get build-dep php5
, not sure if the correct spell for CentOS). -
From the top level directory of the PHP source, cd to
ext/mcrypt
. In this directory, launchphpize
(this should have been installed alongside the aforementioned CentOS equivalentphp5-dev
). This will create a script configuration inext/mcrypt
which will allow you to create mcrypt as a shared module. -
In the same directory,
ext/mcrypt
enter./configure --help
and review the options available to you. Since then, he is very similar to any other Unix application:configure
,make
,make install
.