One: mcrypt introduction
MCrypt is an extension of PHP that completes the encapsulation of commonly used cryptographic algorithms. In fact, the extension is for the MCrypt Standard Class library encapsulation, MCrypt completed a considerable number of commonly used cryptographic algorithms, such as DES, TripleDES, Blowfish (default), 3-way, safer-sk64, safer-sk128, Twofish , tea, RC2 and GOST encryption algorithms, and provide a four-block encryption model for CBC, OFB, CFB and ECB.
Two: Install the Libmcrypt dependent library
To use this extension, you must first install the MCrypt Standard Class library, noting that the MCrypt software relies on Libmcrypt and mhash two libraries.
1. Download Libmcrypt,mhash,mcrypt installation package
Libmcrypt (libmcrypt-2.5.8.tar.gz): http://sourceforge.net/project/showfiles.php?group_id=87941&package_id= 91774&release_id=487459
MCrypt (mcrypt-2.6.8.tar.gz): http://sourceforge.net/project/showfiles.php?group_id=87941&package_id=91948 &release_id=642101
Mhash (mhash-0.9.9.9.tar.gz): http://sourceforge.net/project/showfiles.php?group_id=4286&package_id=4300 &release_id=645636
2. Install Libmcrypt First
#tar-ZXVF libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make Install
Description: Libmcript default installation in/usr/local
Reboot the machine after installation
3. Re-install Mhash
#tar-ZXVF mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make Install
4. Final installation MCrypt
#tar-ZXVF mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH =/usr/local/lib./configure
#make
#make Install
Note: Because the Libmcrypt link library cannot be found when MCrypt is configured, it cannot be compiled because the Libmcrypt link library is under the/usr/local/lib folder.
For this reason, you will want to join the Ld_library_path=/usr/local/lib Import key library when configuring MCrypt.
three. Install php pecl extension mcrypt
Note that MCrypt is the pecl extension of PHP, so just go to PHP to extract the directory to find MCrypt package can.
This is different from the PHP installation of Third-party extensions, reference to PHP installation and use vld view opcode code "PHP install Third-party extension method"
1. Dynamic Loading
The common problem with PHP is that when you compile PHP, you forget to add an extension, and then you want to add an extension, but because you install PHP and then installed some things such as pear, do not want to reload the entire PHP, so you can use dynamic compilation, using Phpize. Note that you need to have exactly the same PHP compression package as the existing PHP .
### #如果你的PHP是用rpm安装的, you need to download a version of the same PHP source code package, and then extract it, switch to the source code in the EXT directory under the specified extension of the module name, and then run Phpize
#cd/usr/php-5.4.8/ext/mcrypt
#/usr/local/webserver/php/bin/phpize
#./configure--with-php-config=/usr/local/webserver/php/bin/php-config
#make && make Install
Add a extension=mcrypt.so to your php.ini.
Restart Apache
#/usr/local/apache2/bin/apachectl Restart
View Phpinfo (), MCrypt, and installed
Installation Complete
--------------------------
2. Static compilation
Add function phpinfo () in any PHP file to get the current configuration of PHP
New configurations to add after these configurations:--with-mcrypt--with-mhash
Then enter the PHP source code directory make clean (must), and then execute this complete configure command, in turn
Make
Make install adds the configuration you want to your needs, for example:
./configure--with-apxs2=/usr/local/web/apache/bin/apxs--with-mcrypt--with-mhash
//./configure--with-apxs2=/usr/local/web/apache/bin/apxs--with-mcrypt--with-mhash--with-libxml-dir-- Enable-bcmath--enable-sockets