PHP--centos under PHP installation MCrypt Extensions (episode)

Source: Internet
Author: User
Tags mcrypt
(The following steps are my actual operation, may be different from your installation method, but I will try to exclude doubts)

Approximate step (1) Install MCrypt, (2) Install PHP extension to MCrypt, (3) Restart Apache

(1), confirm that your Linux is not installed MCrypt library, if installed, skip the installation steps

[root@test-206 ~]# yum list installed|grep mcryptlibmcrypt.x86_64                          2.5.8-4.el5.centos           installedlibmcrypt-devel.x86_64                    2.5.8-4.el5.centos           installedmcrypt.x86_64                             2.6.8-1.el5                  Installed

The above display has been installed, if not, the following two ways to install

(method i) Yum commands lazy people to install

Yum install Libmcrypt libmcrypt-devel mcrypt Mhash
After execution, you will be presented with a library of upcoming installations, which you can x86_64 or i386, such as Yum install libmcrypt.x86_64 (if the Yum command cannot connect to the repository, check your/etc/yum.repos.d/ The file is correct, and your/etc/host is not up to the domain name inside)

Dependencies resolved================================================================================ Package Arch Version Repository size================================================================            ================installing:libmcrypt i386 2.5.7-5.el5 Epel 124 k Libmcrypt               x86_64 2.5.8-4.el5.centos Extras k libmcrypt-devel i386 2.5.7-5.el5 Epel 103 k libmcrypt-devel x86_64 2.5.8-4.el5.centos Extras ten K mcrypt x          86_64 2.6.8-1.el5 Epel k mhash i386 0.9.2-6.el5 Epel 141 k Mhash x86_64 0.9.9-1.el5.rf rpmforge 161 ktransaction summary=========== =====================================================================install 7 Package (s) Upgrade 0 package (s) T Otal Download size:731KIs this OK [y/n]: 
Installed:  libmcrypt.x86_64 0:2.5.8-4.el5.centos  libmcrypt-devel.x86_64 0:2.5.8-4.el5.centos  mcrypt.x86_64 0:2.6.8-1.el5  mhash.x86_64 0:0.9.9-1.el5.rfcomplete!

(method II) Source code compilation installation, go to http://www.sourceforge.net download Libmcrypt,mhash,mcrypt installation package

Libmcrypt (libmcrypt-2.5.8.tar.gz):
MCrypt (mcrypt-2.6.8.tar.gz):
Mhash (mhash-0.9.9.9.tar.gz):

1. Install Libmcrypt First

#tar-ZXVF libmcrypt-2.5.8.tar.gz#cd libmcrypt-2.5.8#./configure#make#make Install Description: Libmcript installed by default in/usr/local

2. Installing Mhash

#tar-ZXVF mhash-0.9.9.9.tar.gz#cd Mhash-0.9.9.9#./configure#make#make Install

3. Installing MCrypt

#tar-zxvf mcrypt-2.6.8.tar.gz#cd mcrypt-2.6.8#ld_library_path=/usr/local/lib./configure#make#make Install

4, finally, or check whether the installation is successful

(2), install PHP mcrypt extension (dynamic load compilation)

Download the mcrypt extension under PHP or download the full installation package for PHP directly

http://cn.php.net/releases/Web page to find the PHP version of their own server, download tar decompression (my is php5.3.3)

Go to Ext/mcrypt folder

[root@*_* 14:45 ~]# CD php-5.3.3/ext/mcrypt/
Execute the phpize command (Phpize is used to extend the PHP extension module, through the phpize can build PHP plug-in module, if not? Yum Install Php53-devel contains, or other methods)
[root@*_* 14:48 mcrypt]# whereis phpize    //In order to determine phpize presence Phpize:/usr/bin/phpize/usr/share/man/man1/phpize.1.gz[ root@*_* 14:48 mcrypt]# phpizeconfiguring for:php API Version:         20090626Zend Module API No:      20090626Zend Extension Api No:   220090626

After execution, you will find that the current directory is more than a few configure files, the final execution of the Php-config command is basically completed

Execute the following command to ensure that your/usr/bin/php-config is present

[root@*_* 15:02 mcrypt]# whereis php-configphp-config:/usr/bin/php-config/usr/share/man/man1/php-config.1.gz[root@ *_* 15:02 mcrypt]#./configure--with-php-config=/usr/bin/php-config
If you encounter any of the following errors, install GCC First, command yum to install GCC
Configure:error:no acceptable C compiler found in $PATH
Until you do not error, appear: Config.status:creating config.h, execute the following command
[root@*_* 15:06 mcrypt]# make && make install
At the end of the final, you will be prompted as follows, stating that you are done

Installing shared extensions:     /usr/lib64/php/modules/

By the way, check if the mrcypt.so extension in/usr/lib64/php/modules/has been created successfully.

Then the thing is simple, add a extension=mcrypt.so to your php.ini

[Root@*_* 15:09 mcrypt]# CD/ETC/PHP.D
Create a Mrcypt.ini file on the line, inside write extension=mcrypt.so

[root@*_* 15:17 php.d]# echo ' extension=mcrypt.so ' > Mcrypt.ini

(3), restart Apache, check the Phpinfo,mcrypt module extension is not loaded

  • 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.