PHP7 pecl 安装 mongodb扩展 和 PHPLIB

安装PECL

//php版本 > 7

$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar

//php版本 < 7
$ yum install php-pear
//否则会报错PHP Parse error: syntax error, unexpected //'new' (T_NEW) in /usr/share/pear/PEAR/Frontend.php on //line 91

安装扩展

$ pecl install mongodb

And if I try to install mongodb for example, I'll get the same warnings as before with an extra "XML Extension not found" at the end.

I compared the "/usr/bin/pecl" with one from ubuntu and the only difference is the "-n" in the exec line :
alpine:
exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"

-n meaning: "No configuration (ini) files will be used"
If not using conf, xml won't be loaded, so I'm pretty sure the "-n" should be removed.

I tested after removing it, and got no warning or anything and was able to install my extension.

以上问题的解决方式:
vi /usr/bin/pecl
remove -n para
删除 -n 参数

安装完毕后,添加库到php.ini


extension=mongodb.so

安装 PHPLIB

http://php.net/manual/zh/mongodb.tutorial.library.php
https://getcomposer.org/download/
安装完毕后,安装 PHP Library for MongoDB (PHPLIB)
$ composer require mongodb/mongodb``<br/>最新版本的命令是:<br/>$ composer.phar require mongodb/mongodb`

一切正确后,在当前目录下,生成:vendor目录,OK

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值