大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
//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
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