CentOS7 PHP Installation MCrypt extension

Source: Internet
Author: User
Tags config php install php mcrypt zend

Transferred from http://www.cnblogs.com/huangzhen/archive/2012/09/12/2681861.html


(The following steps are my actual operation, may be different from your installation method, but I will try to eliminate doubts)

Approximate steps (1) Install MCrypt, (2) Install PHP extensions to MCrypt, (3) Restart Apache

(1) Confirm that your Linux does not have the MCrypt library installed, if installed, skip the installation steps

[root@test-206 ~]# yum list installed|grep mcrypt
libmcrypt.x86_64 2.5.8-4.el5.centos installed libmcrypt-devel.x86_64                    2.5.8-4.el5.centos           installed
mcrypt.x86_64                             2.6.8-1.el5                  installed

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

(method one) Yum command lazy person to install

Yum install Libmcrypt libmcrypt-devel mcrypt Mhash

After the execution will display the related libraries that are about to be installed, you can qualify x86_64 or i386 according to your Linux, such as yum install libmcrypt.x86_64 (if the Yum command cannot connect to the warehouse, please check your/etc/yum.repos.d/ The correctness of the files in, and your/etc/host is not up to the inside of the domain name)

Dependencies resolved ================================================================================ Package Arch Version Repository Size ============================================================ ==================== Installing:libmcrypt i386 2.5.7-5.el5 Epel 124 k Libmcryp               T x86_64 2.5.8-4.el5.centos Extras k libmcrypt-devel i386 2.5.7-5.el5               Epel, K libmcrypt-devel x86_64 2.5.8-4.el5.centos Extras k MCrypt               x86_64 2.6.8-1.el5 Epel k Mhash i386 0.9.2-6.el5 Epel mhash x86_64 0.9.9-1.el5.rf rpmforge 161 k Transaction Summ       ary ================================================================================ Install 7 Package (s) Upgrade 0 Package (s) totalDownload size:731 k is this ok [y/n]: 

Confirm installation, and finally show

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

complete!

(method Two) source code compiles installs, goes to Http://www.sourceforge.net downloads Libmcrypt,mhash,mcrypt installs the package
Libmcrypt (libmcrypt-2.5.8.tar.gz):
MCrypt (mcrypt-2.6.8.tar.gz):
Mhash (mhash-0.9.9.9.tar.gz):
2. Install Libmcrypt First

#tar-zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make


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 to see if the installation was successful

(2), install PHP mcrypt extension (Dynamic loading 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 their own server PHP version, download after the tar decompression (my is php5.3.3)

Enter Ext/mcrypt folder

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

Execute phpize command (Phpize is used to extend the PHP extension module, through Phpize can build PHP plug-in module, if not. Yum install Php53-devel included, or other methods)

[root@*_* 14:48 mcrypt]# whereis phpize    //To determine phpize presence
phpize:/usr/bin/phpize/usr/share/man/man1/ phpize.1.gz
[root@*_* 14:48 mcrypt]# phpize Configuring for
:
PHP Api Version:         20090626
Zend Module API No:      20090626
Zend Extension API No:   220090626

After execution, you will find that the current directory more than a few configure files, the final implementation 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-config php-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 the following error, install GCC First, command yum install gcc

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

Until no error occurs: Config.status:creating config.h, execute the following command

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

At the end of the last, you will be prompted as follows, indicating that you are done

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

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

Then it's easy to 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, lookup 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.