This article describes how to install the mcrypt extension module in PHP in Linux. This article also describes how to install Libmcrypt and mhash. If you need it, refer to the following system environment: centOS6.3.
APACHE: httpd-2.4.2
PHP: php-5.3.21
1. Install mcrypt
1. Download The Libmcrypt, mhash, and mcrypt installation packages.
The Code is as follows:
Libmcrypt-2.5.8.tar.gz
# Wget http://sourceforge.net/project/showfiles.php? Group_id = 87941 & package_id = 91774 & release_id = 487459
Mhash-0.9.9.tar.gz
# Wget http://sourceforge.net/project/showfiles.php? Group_id = 4286 & package_id = 4300 & release_id = 645636
Mcrypt-2.6.8.tar.gz
# Wget http://sourceforge.net/project/showfiles.php? Group_id = 87941 & package_id = 91948 & release_id = 642101
2. Install Libmcrypt first
The Code is as follows:
# Tar-zxvf libmcrypt-2.5.8.tar.gz
# Cd libmcrypt-2.5.8
#/Usr/local/php5/bin/phpize # dynamically compile the php module so that it can be compiled using configure.
#./Configure
# Make
# Make install # libmbench is installed in/usr/local by default.
3. Install mhash
The Code is as follows:
# Tar-zxvf mhash-0.9.9.9.tar.gz
# Cd mhash-0.9.9.9
#/Usr/local/php5/bin/phpize
#./Configure
# Make
# Make install
4. Install mcrypt
The Code is as follows:
# Tar-zxvf mcrypt-2.6.8.tar.gz
# Cd mcrypt-2.6.8
#/Usr/local/php5/bin/phpize
#./Configure -- with-php-config =/usr/local/php5/bin/php-config
# Make
# Make install
After installation, follow the prompts after compilation and installation.
The mcrypt. so module is saved in the/usr/local/php5/lib/php/extensions/no-debug-zts-20090626/directory by default.
5. Load the module to php
The Code is as follows:
# Vi/usr/local/php5/lib/php. ini
Add the following lines:
The Code is as follows:
Extension = "/usr/local/php5/lib/php/extension/ no-debug-zts-20090626/mcrypt. so"
Restart apache:
The Code is as follows:
/Usr/local/apache2/bin/apachectl restart
6. added the phpinfo function to the test page.
Add info. php to/usr/local/apache2/htdocs/to test whether the php module is loaded.
The Code is as follows:
# Vi/usr/local/apache2/htdocs/info. php
---------------
<? Php
Echo phpinfo ();
?>
---------------
Check whether port 80 is enabled
The Code is as follows:
# Lsof-I: 80
Enter http: // localhost/info. php In the browser
The following test page is displayed. The mcrypt. so module is successfully loaded under PHP.