Simple analysis of PHP installation extension mcrypt and related dependencies (PHP installation pecl extension method)

Source: Internet
Author: User
Tags config install php mcrypt php file php and phpinfo

One: mcrypt introduction
mcrypt is an extension of PHP that completes the encapsulation of common 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 Libmcrypt dependent Libraries
to use this extension, you must first install the MCrypt Standard Class library, noting that MCrypt software relies on Libmcrypt and mhash two libraries.

1. Download Libmcrypt,mhash,mcrypt installation package
Libmcrypt (libmcrypt-2.5.8.tar.gz): click Link
mcrypt (mcrypt-2.6.8.tar.gz ): Click link
Mhash (mhash-0.9.9.9.tar.gz): Click link

2. Install Libmcrypt First #tar-zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make Install
Description: Libmcript The default installation in/usr/local
Reboot machine after installation

3. Reinstall Mhash
#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
Description: Because the Libmcrypt link library cannot be found when the MCrypt is configured, it cannot be compiled because the Libmcrypt link library is in/usr The/local/lib folder.
Because of times, to join the Ld_library_path=/usr/local/lib Import key library when configuring MCrypt.

three. Install php pecl extension mcrypt
Note MCrypt is the pecl extension of PHP, so just go to the zip directory of PHP to find MCrypt package.


1. Dynamic loading
The common problem with PHP is that you forget to add an extension when you compile PHP, and then you want to add an extension, but because you install PHP and then put some things like 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.
#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
adds an ex to your php.initension=mcrypt.so

Restart Apache
#/usr/local/apache2/bin/apachectl Restart
View phpinfo (), MCrypt and installation of
Installation complete
--------------------------
2. Static compilation
add functions to any PHP file Phpinfo (), You can get the current configuration of PHP
Add the configuration to add after these configurations:--with-mcrypt--with-mhash
and then enter the PHP source directory made clean (necessary), and then execute this complete configure command , and then

Make
make install
Add the configuration you want, 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.