PHP configuration MCrypt Extended Detailed steps

Source: Internet
Author: User
Tags install php mcrypt php source code phpinfo

This article is mostly someone else's, just according to their own use of the process added a little note, I hope the original author do not mind.

The rationale is: First make the MCrypt software run, then install the PHP extension module and configure it in php.ini.

Note here that the MCrypt software relies on Libmcrypt and mhash two libraries, so the installation configuration order is from right to left

First, download and install MCrypt

1. Direct Baidu search Three package name libmcrypt-2.5.8.tar.gz,mcrypt-2.6.8.tar.gz, mhash- can download the

Libmcrypt (libmcrypt-2.5.8.tar.gz):

MCrypt (mcrypt-2.6.8.tar.gz):

Mhash (mhash-

2. Install Libmcrypt First

#tar-ZXVF libmcrypt-2.5.8.tar.gz

#cd libmcrypt-2.5.8



#make Install Description: Libmcript default installation in/usr/local/lib

3. Install Mhash

#tar-ZXVF mhash-

#cd mhash-



#make install is installed by default in/usr/local/lib

4. Install MCrypt

#tar-ZXVF mcrypt-2.6.8.tar.gz

#cd mcrypt-2.6.8

#LD_LIBRARY_PATH =/usr/local/lib./configure


#make install is installed by default in/usr/local/bin

Note: Because the Libmcrypt link library cannot be found when MCrypt is configured, it cannot be compiled because the Libmcrypt link library is under the/usr/local/folder. To join the Ld_library_path=/usr/local Import key library when configuring MCrypt

When installed (make install) take a look at where the installation is, that is, to see if your installation directory is correct

Second, install the PHP expansion module

1. Static compilation (This I have not tried)

Add function phpinfo () in any PHP file to get the current configuration of PHP

New configurations to add after these configurations: ' –with-mcrypt=/usr/local/include '

Then enter the PHP source code directory, execute this complete configure command

Configuration complete, the following source code package production and installation

Make clean (must be required)


Make install

2. Dynamic loading (This is when you have installed PHP, in the existing PHP to add mcrypt extension method)

The common problem with PHP is that when you compile PHP, you forget to add an extension, and then you want to add an extension, but because you install PHP and then installed some things such as pear, do not want to delete the directory reload, so you can use Phpize. The method is:

To have exactly the same PHP compression pack as the existing PHP (this is very important and must be the same version as the PHP you have installed.) You can run Phpinfo in your Apache () function to view your PHP version). I'm using a php-5.2.6.tar.gz. Expand into the Inside Ext/mcrypt directory (which is a mcrypt PHP extension) and execute/usr/local/php/bin/phpize (you can try Whereis phpize to find out where phpize is in your system). Phpize is a tool installed when installing PHP, if your machine does not have phpize tools installed, then you may want to make,make install PHP, just to get phpize.

After the execution, you will find that the current directory more than a few configure files, if no error, then run according to the prompts


Note that you first make sure that the/usr/local/php/bin/php-config exists (using Whereis php-config to find out where the php-config in the system is).


Make install

After make install the system will output the directory where you files. Copy the Extension_dir in the directory pointed to by the php.ini indicated in the. Modify PHP.ini, add a sentence at the end

Extension= the output of the directory name/

Restart the Apache service

You can restart Apache using the service httpd restart

If you can't reboot, try using killall httpd to kill all of the Apache processes. Then service httpd start

, everything OK.

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