打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
ubuntu 上给PHP安装扩展 Msgpack 和 Yar
什么是PEAR?什么是PECL?PHP中两个容易混淆的概念解释
Tsung‘s Blog | Debian PHP APC 安裝
诚之和:php7安装openssl扩展的方法教程
安装memcache到Centos 5.3
PHP 加速器:APC、eAccelerator、XCache比较
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服