RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
PHP7pecl安装mongodb扩展和PHPLIB

安装PECL

//php版本 > 7

创新互联专注为客户提供全方位的互联网综合服务,包含不限于做网站、成都网站设计、西峡网络推广、重庆小程序开发、西峡网络营销、西峡企业策划、西峡品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供西峡建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com

$ 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``
最新版本的命令是:
$ composer.phar require mongodb/mongodb`

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


名称栏目:PHP7pecl安装mongodb扩展和PHPLIB
网页网址:http://sczitong.cn/article/jigcii.html