Easiest way to install Mongodb PHP extension in Ubuntu 13.10 (saucy)?
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-pearsudo pecl install mongosudo echo "extension=mongo.so" | sudo tee /etc/php5/mods-available/mongo.ini
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
There is also a good way to install the mongo DB for PHP. I have ubuntu 14.04LTS.
open synaptic package manager and search "mongo"
select these packages to install.
- php-horde-mongo
- php-mongo
click apply to install the packages.
Now restart you apache2 using this command.
sudo service apache2 restart
Test the mongo
create the PHP file with name mongo-test.php and paste this code there.
<?php // connect to mongodb $m = new MongoClient(); echo "Connection to database successfully"; // select a database $db = $m->mydb; echo "Database mydb selected";?>
test this URL http://localhost/mongo-test.php