php扩展模块安装

PECL 的全称是 The PHP Extension Community Library ,是一个开放的并通过 PEAR(PHP Extension and Application Repository,PHP 扩展和应用仓库)打包格式来打包安装的 PHP扩展库仓库。通过 PEAR 的 Package Manager 的安装管理方式,可以对 PECL 模块进行下载和安装。

[root@chy ~]# cd /usr/local/src/
[root@chy src]# wget https://codeload.github.com/phpredis/phpredis/zip/develop 
(首先下载一个develop包)
[root@chy src]# du -sh develop 
220K    develop
[root@chy src]# mv develop phpredis-develop.zip
(将这个develop改名字)
[root@chy src]# unzip phpredis-develop.zip 
[root@chy src]# cd phpredis-develop
[root@chy phpredis-develop]# 
[root@chy phpredis-develop]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
(这里报错少autoconf)
[root@chy phpredis-develop]# yum install -y autoconf
(安装此包)
[root@chy phpredis-develop]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
(生成configure文件)
[root@chy phpredis-develop]# ./configure --with-php-config=/usr/local/php/bin/php-config
(编译)
[root@chy phpredis-develop]# echo $?
0
(成功)
[root@chy phpredis-develop]# make &&make install
[root@chy phpredis-develop]# ls  /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
opcache.so  redis.so
(redis.so这个是扩展模块)
[root@chy phpredis-develop]# /usr/local/php/bin/php -m |grep redis
(并没有找到此模块)
[root@chy phpredis-develop]# /usr/local/php/bin/php -i |grep extension_dir
extension_dir => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 => /usr/local/php/lib/php/extensions/no-debug-zts-20131226
sqlite3.extension_dir => no value => no value
(查看扩展模块存放目录,我们可以在php.ini中去自定义该路径) 
[root@chy phpredis-develop]# vi /usr/local/php/etc/php.ini 
;extension=php_shmop.dll
extension = redis.so
(增加extension = redis.so 这个可以在最后加也可以在;extension=php_shmop.dll这个的后面增加)
[root@chy phpredis-develop]# /usr/local/php/bin/php -m |grep redis
redis
(查看已经增加了此模块)