PHP installation extension mcrypt and related dependencies [How to install PECL extension in PHP]
1: Introduction to Mcrypt
Mcrypt is an extension of PHP that completes the encapsulation of commonly used encryption algorithms. In fact, this extension is an encapsulation of the mcrypt standard library. mcrypt has completed quite a few commonly used encryption algorithms, such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST encryption algorithm, and provides CBC, OFB, CFB and ECB four block encryption models.
Two: Install libmcrypt dependency library
To use this extension, the mcrypt standard library must be installed first . Note that the mcrypt software depends on two libraries, libmcrypt and mhash.
1. Download the Libmcrypt, mhash, mcrypt installation packages
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 is installed in /usr/local by default
Restart the machine after installation
3. Install mhash again
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
4. Finally install 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: When configuring Mcrypt , the link library of libmcrypt cannot be found, resulting in failure to compile, because the link library of libmcrypt is in the /usr/local/lib folder.
Therefore, when configuring mcrypt , add LD_LIBRARY_PATH=/usr/local/lib to import the key link library.
3. Install PHP's Pecl extension mcrypt
Note that mcrypt is the Pecl extension that comes with PHP, so just go to the PHP decompression directory to find the mcrypt package.
This is different from installing third-party extensions in PHP. Refer to PHP installation and using VLD to view opcode code [ Methods for installing third-party extensions in PHP]
1. Dynamic loading
The common problem of using php is: forget to add an extension when compiling php, and then want to add an extension, but because after installing php, some things such as PEAR are installed, and do not want to reinstall the entire PHP, so you can use dynamic compilation and use phpize. It should be noted that there must be a php compressed package that is exactly the same as the existing php .
#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 an extension=mcrypt.so to your php.ini
restart apache
#/usr/local/apache2/bin/apachectl restart
View phpinfo(), mcrypt and installed
The installation is complete
--------------------------
2. Static compilation
Add the function phpinfo() to any PHP file to get the current PHP
configuration. Add the configuration that needs to be added after these configurations: --with-mcrypt --with-mhash
Then enter the php source code directory make clean (must be required), and then execute this complete configure command, followed by
make
make install
Add the required configuration according 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