Pecl全称The PHP Extension Community Library,php社区扩展库,由社区编写,维护。使用pecl方便之处在于我们不用到处找源码包下载编译,配置,不用手动phpize,configure,make,make install,自动识别模块安装路径,我们只需要编辑php.ini配置文件开启扩展,当然我们也需要自己配置一些参数的时候可以先下载源码再构建

安装pecl

Apt

sudo apt-get install php-dev php-pear autoconf,automake,libtool  -y 

Yum

sudo yum install php-dev php-pear autoconf,automake,libtool  -y 

pecl常用命令

build                  从C的源码中构建扩展
install                安装一个包,步骤包含(configure,make,make install)
download               下载源码包
list-all               列出全部包
run-tests              运行测试(make test)

更多

pecl --help

安装MongoDB扩展

sudo pecl install mongodb

配置PHP.ini

Redhat

extension=mongodb.so

Debian/Ubuntu

sudo vim  /etc/php/7.0/mods-available/mongodb.ini
; configuration for php mongodb module
; priority=20
extension=mongodb.so

Zend扩展

zend_extension=opcache.so
sudo phpenmod mongodb

确认是否安装成功

➜ php -m | grep mongodb
mongodb


https://www.myfreax.com/install-the-php-extension-with-pecl/