1.pecl安装。

之前不知道怎么安装上的,但是在使用过程中 会出现很多的warning:

Warning: Invalid argument supplied for foreach() in Command.php on line 259

Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259

...etc etc etc...

Notice: Undefined index: honorsbaseinstall in Role.php on line 180

Notice: Undefined index: honorsbaseinstall in Role.php on line 180

...etc etc etc...

Notice: Undefined index: installable in Role.php on line 145

Notice: Undefined index: installable in Role.php on line 145
...

这个问题,可能是安装的pecl版本与php版本不对应所导致的,

解决方法:1.yum erase php-pear 卸载php-pear

      2.rm -rf /usr/share/pear/ 删除残留

      3.yum install php56w-pear 安装5.6版本PHP对应的扩展,ok,pecl已经可以正常使用了.

使用pecl安装mongodb的扩展,yum install mongodb,嗯,安装完成。。。但是使用时候,会出现:PHP 'MongoClient' Not Found......

挥之不去....查了很多资料 包括PHP -M PHPINFO PHP -I|GREP "MONGO",等等,都是正常的,但是就是不能正常使用。此时的mongodb扩展的版本为1.1.5

放弃,选择从新编译安装。

编译安装步骤:

1.官网 http://php.net/manual/zh/mongo.installation.php

2.去github下载,https://github.com/mongodb/mongo-php-driver-legacy,适当的阅读文档说明,之后找到git链接

3.在服务器上任意目录download,git clone https://github.com/mongodb/mongo-php-driver-legacy.git     获取源码包。

4.按照

To build and install the driver:

phpize
./configure
make
sudo make install

Then, add the following to your php.ini file:

extension=mongo.so

此处需要注意一点,由于之前pecl安装过了,要将之前的有问题的扩展删除:rm -rf /usr/lib64/php/modules/mongodb.so   屏蔽:extension=mongodb.so   OK.

重启服务器,发现已经可以正常使用了。版本1.7.0dev。

我觉得是pecl安装版本过低的缘故。