Install mcrypt extension in php in CentOS

Source: Internet
Author: User
Tags mcrypt tar unzip
Install the mcrypt extension in php in CentOS (the following steps are my actual operations, which may be different from your installation method, but I will try my best to eliminate the problem)

General steps (1) install mcrypt, (2) install php extension for mcrypt, (3) restart apache

(1) confirm that the mcrypt library is not installed in your linux. if you have installed the mcrypt Library, 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 shows that it has been installed. if not, install it in either of the following ways:

(Method 1) install the yum command

yum install libmcrypt libmcrypt-devel mcrypt mhash

After the command is executed, the relevant library to be installed will be displayed. you can set x86_64 or i386 according to your linux restrictions, such as yum install libmcrypt. x86_64 (if the yum command cannot connect to the repository, check your/etc/yum. repos. d/, and whether your/etc/host can reach the domain name)

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        105 k libmcrypt-devel      i386        2.5.7-5.el5               epel          103 k libmcrypt-devel      x86_64      2.5.8-4.el5.centos        extras         10 k mcrypt               x86_64      2.6.8-1.el5               epel           88 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)Total download size: 731 kIs this ok [y/N]:

Confirm installation and display

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 2) source code compilation and installation, go to the http://www.sourceforge.net to 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.tar.gz ):
2. install Libmcrypt first

# Tar-zxvf libmcrypt-2.5.8.tar.gz # cd libmcrypt-2.5.8 #./configure # make install description: libm1_default installation in/usr/local


3. install mhash

#tar -zxvf mhash-0.9.9.9.tar.gz#cd mhash-0.9.9.9#./configure#make#make install

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

Finally, check whether the installation is successful.

(2) install the mcrypt extension of php (dynamic loading and compilation)

Download the mcrypt extension in php or directly download the complete php installation package

Http://cn.php.net/releases/ web page to find your own server php version, download tar unzip (my php5.3.3)

Go to the ext/mcrypt folder

[root@*_* 14:45 ~]# cd php-5.3.3/ext/mcrypt/

Run the phpize command (phpize is used to expand the php Extension Module. you can use phpize to create a php plug-in module. If no? The yum install php53-devel contains, or other methods)

[Root @ * _ * mcrypt] # whereis phpize // to confirm that phpize exists: /usr/bin/phpize/usr/share/man/man1/phpize.1.gz [root @ * _ * 14:48 mcrypt] # phpizeConfiguring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626

After the execution, you will find that some configure files are added to the current directory, and the php-config command is basically completed.

Run the following command to ensure that your/usr/bin/php-config exists.

[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 the following error occurs, install gcc first and run the command yum install gcc

configure: error: no acceptable C compiler found in $PATH

If no error is reported, config. status: creating config. h is displayed. run the following command:

[root@*_* 15:06 mcrypt]# make && make install

At the end, you will be prompted as follows, indicating that you have achieved success.

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

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

The next step is simple. add extension = mcrypt. so to your php. ini file.

[root@*_* 15:09 mcrypt]# cd /etc/php.d

Create a mrcypt. ini file and write extension = mcrypt. so.

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

(3) restart apache. check phpinfo and whether the mcrypt Module extension is 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.