KajMagnus
KajMagnus

Reputation: 11696

How install PHP's MongoDB driver — "pecl install mongo" fails

How do I install PHP's MongoDB client driver?

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. 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. — How do I install the Mongo driver?

Some details:

  1. OS: Linux Mint 16, which is based on Ubuntu.

  2. pecl list-channels says:

     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
    

Upvotes: 10

Views: 20831

Answers (4)

RASEL RANA
RASEL RANA

Reputation: 2190

In Ubuntu 20.04, php-mongodb is outdated and you'll need the PECL method to install the latest version of MongoDB.

First, install the php-pear and php-dev plugin

sudo apt install php-dev php-pear

Then

sudo pecl install mongodb

Upvotes: 0

ivanivan
ivanivan

Reputation: 2225

sudo apt-get install php-mongodb

Assuming of course that you installed php, etc. via apt-get as well (or synapic, etc)

Upvotes: 1

Barney D.
Barney D.

Reputation: 67

I had the same problem while trying to create a working Docker container for a Laravel app. The following worked for me:

sudo pecl install mongodb

I found this referenced in the PHP docs comments.

Upvotes: 0

maximx1
maximx1

Reputation: 89

I don't know how locked into the pecl method you are, but I recently compiled the driver. This was on an ubuntu server. It installs the .so and all you have to do is just add "extension=mongo.so" to the php.ini files.

Upvotes: 3

Related Questions