Summary of various methods for installing PHP extensions under CentOS system

Source: Internet
Author: User
Tags fpm install php ini mcrypt phpinfo redis zts centos

Installing PHP Extensions

# wget Http://pecl.php.net/get/gearman-1.1.1.tgz
# tar ZXVF gearman-1.1.1.tgz
# CD gearman-1.1.1
#/usr/local/server/php/bin/phpize
#./configure--with-php-config=/usr/local/server/php/bin/php-config--with-gearman=/usr/local/server/ gearmand-1.1.7/
# Make && make install
The above steps will output the extended installation directory:/usr/local/server/php-5.4.14/lib/php/extensions/no-debug-non-zts-20100525/
To modify PHP.ini, add the following join statement:
Extension=/usr/local/server/php-5.4.14/lib/php/extensions/no-debug-non-zts-20100525/gearman.so

Reboot the PHP-FPM and use Phpinfo to see if the installation was successful
# Service PHP-FPM Restart

Note:

When you install the PHP extension, it is possible that the installation failed because of a version problem. So you'd better go to the official website to see the latest version

Install PHP extensions MCrypt

I download installation mcrypt
 
1. First go to http://www.sourceforge.net download Libmcrypt,mhash,mcrypt installation package, below is the link I found
 
 libmcrypt (libmcrypt-2.5.8.tar.gz): http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/
&NBSP
MCrypt (mcrypt-2.6.8.tar.gz): Http://sourceforge.net/project/showfiles.php?group_id=87941&package_ id=91948&release_id=642101
 
Mhash (mhash-0.9.9.9.tar.gz): http://sourceforge.net/project/ showfiles.php?group_id=4286&package_id=4300&release_id=645636
 
 
2. Install Libmcrypt First
TAR-ZXVF libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure
Make
make install
 
Description: Libmcrypt is installed by default 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
Export Ld_library_path=/usr/local/lib
./configure
Make
make install

The general method of dynamically installing PHP extensions (figure)

First, explain the following Linux commands:

./configure #脚本配置工具

./configure--help #查看脚本配置工具configure的命令行选项

/usr/local/php/bin/phpize#phpsize command to extend a module in a compiled PHP

1. Download the package you want to install, extract the directory (such as: Phpredis)

2. Enter the package directory (CD Phpredis)

3. Execute phpsize command (phpize)

4. Configuration (./configure--with-php-config=/usr/local/php/bin/php-config #指定安装PHP时候的配置)

(Attached: The general method of specifying the location of the installation directory:--with-php-mysql=/usr/local/mysql# Specify the MySQL database location)

5. Compile installation (make && make install)

6. Successful compilation

At this point, the generated redis.so file is in this directory, and the local browser can also view the file:///usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

7. Modify PHP configuration file (Vim/usr/local/php/etc/php.ini)

Add: extention = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/redis.so";

8. Reboot the server (/root/lnmp reload #重启nginx和PHP, according to your own environment)

Use Phpinfo () to view the PHP configuration list in the browser, OK, this installation is complete.

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.