每天进步一点点: 手动安装指定版本的MongoDB PHP Driver

in #cn5 years ago (edited)

在尝试安装某项目时,遇到了如下错误提示:

mongodb/mongodb 1.3.2 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb is missing from your system.

但是通过Ubuntu包管理器安装的只有1.3.4版本即:php-mongodb_1.3.4,这不符合版本要求,所以只有考虑手动安装。


(图源 :pixabay)

驱动兼容

驱动兼容页面,我们可以看到如下兼容关心,因为我用的是PHP7.2,所以原则上可以安装MongoDB 的1.3.x、1.4.x或者1.5.x的PHP驱动。

尽管在https://docs.mongodb.com/ecosystem/drivers/php/ 这个页面中说明可以用 PECL或者 Composer来安装MongoDB PHP Driver,但是我没搞明白怎么选择版本。

手动安装

不过我在PHP.NET上找到了一个Manually Installing the MongoDB PHP Driver

git clone https://github.com/mongodb/mongo-php-driver.git
cd mongo-php-driver
git submodule update --init
phpize
./configure
make all
sudo make install

因为我要选择版本,所以还要在进入目录后,添加这样一句(比如安装1.5.5版本):

git checkout 1.5.5

补充

除了从github获取源文件外,还可以直接从PECL的下载页面获取,地址为:
https://pecl.php.net/package/mongodb

想要1.5.5版本的话,直接执行下列命令即可:

wget https://pecl.php.net/get/mongodb-1.5.5.tgz
tar xzvf mongodb-1.5.5.tgz

其它手动安装的步骤基本不变。

结果

按上述手动安装步骤安装后,之前出现的错误提示就消失啦。可是整个项目我还是没有安全配置明白,完全在自己的技能树之外。不过前进一点是一点吧,想必终将会整明白的。

相关链接


Vote For Me As Witness
https://steemit.com/~witnesses type in oflyhigh and click VOTE

Vote @oflyhigh via Steemconnect
Thank you!

Sort:  

恭喜你!您的这篇文章入选 @justyy 今日 (2019-07-06) 榜单 【优秀的文章】, 回复本条评论24小时内领赏,点赞本评论将支持 @dailychina 并增加将来您的奖赏。
@justyy 是CN区的见证人,请支持他,给他投票,或者设置justyy为见证人代理。感谢!@justyy的主要贡献:https://steemyy.com

Congratulations! This post has been selected by @justyy as today's (2019-07-06) 【Good Posts】, Steem On! Reply to this message in 24 hours to get rewards. Upvote this comment to support the @dailychina and increase your future rewards! ^_^

SteemIt 工具、API接口、机器人和教程
SteemIt Tools, Bots, APIs and Tutorial



If you believe what I am doing, please consider a spare vote voting me here, thank you very much indeed.

@justyy - the author of https://SteemYY.com and I have been a Steem Witness for more than a year now.

区块链中文第一大银行简介:你的比特币拿不了利息,但是你把比特币换成steem后就能拿利息了!

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 63196.13
ETH 3385.94
USDT 1.00
SBD 2.45