ubuntu php mongodb 扩展安装 / 升级

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu php mongodb 扩展安装 / 升级相关的知识,希望对你有一定的参考价值。

* composer 安装 mongodb 时候出现版本提示:

```
Your requirements could not be resolved to an installable set of packages.
Problem 1
- mongodb/mongodb 1.4.1 requires ext-mongodb ^1.5.0 -> the requested php extension mongodb has the wrong version (1.1.5) installed.
- mongodb/mongodb 1.4.0 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb has the wrong version (1.1.5) installed.
- mongodb/mongodb 1.3.2 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb has the wrong version (1.1.5) installed.
- mongodb/mongodb 1.3.1 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb has the wrong version (1.1.5) installed.
- mongodb/mongodb 1.3.0 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb has the wrong version (1.1.5) installed.
- Installation request for mongodb/mongodb ^1.3 -> satisfiable by mongodb/mongodb[1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1].

查看 php 的mongodb 扩展: echo phpinfo();

更新扩展

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
apt-get install php7.0-mongodb



重启启动 apache
` sudo systemctl restart apache2.service `

重启后刷新 phpinfo 才看到 mongodb 的版本变化。

以上是关于ubuntu php mongodb 扩展安装 / 升级的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu下安装PHP的mongodb扩展操作命令

将 mongodb 扩展添加到 PHP-7.1.9 XAMPP Ubuntu

将mongodb扩展添加到PHP-7.1.9 XAMPP Ubuntu

[PHP]新版的mongodb扩展安装和使用

在 Ubuntu 13.10 (saucy) 中安装 Mongodb PHP 扩展的最简单方法?

wamp环境PHP安装mongodb扩展