简体   繁体   English

如何安装 PHP 的 MongoDB 驱动程序——“pecl install mongo”失败

[英]How install PHP's MongoDB driver — “pecl install mongo” fails

How do I install PHP's MongoDB client driver?如何安装 PHP 的 MongoDB 客户端驱动程序?

I've done this already:我已经这样做了:

  $ sudo aptitude install php5-dev php5-cli php-pear make

But the next step fails:但是下一步失败了:

  $ sudo pecl install mongo
  No releases available for package "pecl.php.net/mongo"
  install failed

When I have a look at http://pecl.php.net/mongo , I find listed many versions of the Mongo driver.当我查看http://pecl.php.net/mongo 时,我发现列出了许多版本的 Mongo 驱动程序。 Am I supposed to include a version number or something?我应该包括一个版本号还是什么? However all installation instructions I've found simply state that one use sudo pecl install mongo and nothing else.然而,我发现的所有安装说明都只是说明一个人使用sudo pecl install mongo而没有别的。 — How do I install the Mongo driver? — 如何安装 Mongo 驱动程序?

Some details:一些细节:

  1. OS: Linux Mint 16, which is based on Ubuntu.操作系统:Linux Mint 16,基于 Ubuntu。

  2. pecl list-channels says: pecl list-channels说:

     Registered Channels: Channel Alias Summary doc.php.net phpdocs PHP Documentation Team pear.php.net pear PHP Extension and Application Repository pecl.php.net pecl PHP Extension Community Library __uri __uri Pseudo-channel for static packages

I don't know how locked into the pecl method you are, but I recently compiled the driver .我不知道你对 pecl 方法有多锁定,但我最近编译了驱动程序 This was on an ubuntu server.这是在 ubuntu 服务器上。 It installs the .so and all you have to do is just add "extension=mongo.so" to the php.ini files.它会安装 .so,您所要做的就是将“extension=mongo.so”添加到 php.ini 文件中。

I had the same problem while trying to create a working Docker container for a Laravel app.我在尝试为 Laravel 应用程序创建一个可用的 Docker 容器时遇到了同样的问题。 The following worked for me:以下对我有用:

sudo pecl install mongodb

I found this referenced in the PHP docs comments .我在PHP 文档注释中发现了这一点。

sudo apt-get install php-mongodb

当然,假设您也通过 apt-get 安装了 php 等(或 Synapic 等)

In Ubuntu 20.04, php-mongodb is outdated and you'll need the PECL method to install the latest version of MongoDB.在 Ubuntu 20.04 中,php-mongodb 已过时,您需要使用 PECL 方法来安装最新版本的 MongoDB。

First, install the php-pear and php-dev plugin首先,安装php-pear和php-dev插件

sudo apt install php-dev php-pear

Then然后

sudo pecl install mongodb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM