Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest way to install Mongodb PHP extension in Ubuntu 13.10 (saucy)?

Tags:

I'm using Ubuntu 13.10 (saucy salamander) and I was hoping that sudo apt-get install php5-mongo would be enough to get the mongodb database driver installed.

No such luck though. I'm using php5-fpm, so firstly I found I also needed to do php5enmod mongo but even with that, I get a error:

include(MongoClient.php): failed to open stream: No such file or directory

Instead, to install I have to do the following (which uses a lot more disk space):

 sudo apt-get install php5-dev make php-pear
 sudo pecl install mongo
 sudo echo "extension=mongo.so" | tee /etc/php5/mods-available/mongo.ini

My question is why isn't sudo apt-get install php5-mongo enough? Is it a problem with the Ubuntu repo? How can I look into the ubuntu repositories and find what version it uses or why MongoClient.php isn't included. I'm using the "ubuntu:saucy" docker image as my base and it includes universe by default I think.

like image 867
Tom Avatar asked Mar 17 '14 15:03

Tom


2 Answers

In Ubuntu 14.04, sudo apt-get install php5-mongo results in a fully working mongo PHP extension. So I guess there is just a packaging problem in Ubuntu 13.10 which causes the problem.

Solution: Use Ubuntu 14.04 LTS instead of Ubuntu 13.10.

But, if you have to use Ubuntu 13.10, don't use the php5-mongo Ubuntu package, instead install the mongo extension via pecl:

sudo apt-get install php5-dev make php-pear
sudo pecl install mongo
sudo echo "extension=mongo.so" | sudo tee /etc/php5/mods-available/mongo.ini
like image 88
Tom Avatar answered Oct 25 '22 18:10

Tom


The easiest to install the mongoDB driver for php5 in ubuntu is using the command :

sudo apt-get install php5-mongo

Attention, the driver is correctly installed but not loaded yet, so should absolutly restart the server, if using apache should do :

sudo service apache2 restart
like image 20
Yassine Khachlek Avatar answered Oct 25 '22 20:10

Yassine Khachlek