Linux environment PHP MCrypt extended Full installation Notes

Source: Internet
Author: User
Tags ini mcrypt

If your PHP site/var/log/httpd/error_log the following error:

PHP Fatal error:call to undefined function mcrypt_get_block_size () In/var/www/html/miniblog/system/classes/class_ des.php on line 40

Heart presumably is MCrypt not installed

The installation steps are as follows:

1. View current PHP version #php-version

2. If the current Linux PHP has the best source code package, if there is no source code package, need to download a original code package, upload to the server decompression

3. Confirm that Libmcrypt is installed
Ldconfig-p | grep libmcrypt

If not installed:
Download Address: Http://sourceforge.net/projects/mcrypt
Can download both Libmcrypt and MCrypt
Install Libmcrypt First, default installation directory for/usr/local, PHP manual recommendation? Disable-posix-threads, somehow
./configure && make && make install
Ldconfig

Install MCrypt again, the default installation directory is/usr/local
./configure? with-libmcrypt-prefix=/usr/local

4. Confirm that Mhash is installed
Ldconfig-p | grep Mhash

If not installed:
Download Address: http://mhash.sourceforge.net/
./configure && make && make install
Ldconfig

5. Enter the source directory, install the MCrypt module, this step will generate a mcrypt.so file
CD Php-x.x.x/ext/mcrypt
./configure with-mcrypt=/usr/local/&& make && make install

6. Add one line at the back of the/etc/php.ini: extension=/usr/lib/php/modules/mcrypt.so

7. Restart PHP #service httpd restart


Install the MCrypt module for PHP under Linux

When you get to work, you receive the research and development site "call to undefined function Mcrypt_create_iv ()"
Online check is not installed MCrypt module.
Search, most of the online methods are installed MCrypt module to recompile PHP, but my system is running online, not easy to compile.
Here's my process:
Environment: Rhel 5 +php5.3, yum

#yum-y install libmcrypt libmcrypt-devel php-mcrypt php-mbstring

Find related files
#updatedb
#locate mcrypt.so
/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so

#locate Libmcrypt
/usr/local/bin/libmcrypt-config
/usr/local/lib/libmcrypt
/usr/local/lib/libmcrypt.la
/usr/local/lib/libmcrypt.so
/usr/local/lib/libmcrypt.so.4
/usr/local/lib/libmcrypt.so.4.4.8

With these two data, we can add MCrypt modules on the php.ini.


#locate php.ini
/usr/local/php5/lib/php.ini

#vi/usr/local/php5/lib/php.ini
Add two lines
Extension=mcrypt.so
; Default:compiled in Into Libmcrypt (Usually/usr/local/lib/libmcrypt)
; mcrypt.modes_dir=
mcrypt.modes_dir=/usr/local/lib/
: Wq Save Exit

To restart Apache

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.