Analysis of PHP installation extension mcrypt and related dependencies (the method for installing PECL extension in PHP)

Source: Internet
Author: User
Tags mcrypt phpinfo

I. Introduction to mcrypt
Mcrypt is an extension of PHP and implements Common encryption.Algorithm. In fact, the extension is the encapsulation of mcrypt standard class library, mcrypt completed a lot of common encryption algorithms, such as des, tripledes, blowfish (default), 3-way, SAFER-SK64, SAFER-SK128, twofish, tea, RC2 and GOST encryption algorithms, and provides four block encryption models: CBC, ofB, CFB, and ECB.

Ii. Install the libmcrypt dependent Library
To use this extension, you must first install the mcrypt standard class library. Note that the mcrypt software depends on libmcrypt and mhash libraries.

1. Download The libmcrypt, mhash, and mcrypt installation packages.
Libmcrypt(libmcrypt-2.5.8.tar.gz ):Click link
Mcrypt(mcrypt-2.6.8.tar.gz ):Click link
Mhash(mhash-0.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
Note: libmbench is installed on/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 mcrypt is configured, The libmcrypt Link Library cannot be found, resulting in compilation failure because the libmcrypt Link Library is in the/usr/local/lib folder.
For this reason, LD_LIBRARY_PATH =/usr/local/lib must be added when mcrypt is configured to import the key library.

3. Install the PECL extension mcrypt of PHP
Note that mcrypt is the PECL extension of PHP, so you only need to find the mcrypt package in the decompressed directory of PHP.


1. dynamic Loading
the common problem with using PHP is: I forgot to add an extension when compiling PHP and want to add it later, however, because some things such as pear are installed after PHP is installed and you do not want to reinstall the entire PHP, you can use dynamic compilation and phpize. Note that there must be a PHP compressed package identical to 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
to your php. INI adds an extension = mcrypt. so

restart apache
#/usr/local/apache2/bin/apachectl restart
View phpinfo (), mcrypt and installation completed
------------------------
2. static compilation
Add the phpinfo () function to any PHP file to obtain the current PHP configuration.
Add the configuration to be added after these configurations: -- With-mcrypt -- With-mhash
, enter the PHP source code directory make clean (required), and then execute the complete configure command,

make
make install
Add the configuration as required, 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.