Working with latest versions of ubuntu has been nothing short of a harrowing experience. finding the right parts to fit into the command-line to get the mongo up and running for PHP. After struggling for the past 1-2 hours, here is the solution:
1. Install the mongo release for Ubuntu, which are apt-get packages by 10gen.
write this in your command line:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
then, copy this line to the end of your /etc/apt/sources.list file
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
then, do this:
sudo apt-get update
sudo apt-get install mongodb-10gen
2. After this, install the mongo.so driver for PHP. For this you'd need PEAR with a PECL repository. For getting PEAR, do a
sudo apt-get install php-pear
Now, coming back to the point, to install mongo for PHP, do this: (if admin, remove the sudo part)
pecl search mongo
sudo pecl install mongo
(Note: if you encounter an error such as :
sh: phpize: command not found ERROR: 'phpize' failed
then install php5-dev by running
sudo apt-get install php5-dev
and then run the pecl install mongo again.)
Read the full details here: http://www.if-not-true-then-false.com/2010/install-php-mongodb-mongo-driver-on-linux-mac-os-x-windows-unix-bsd/
(Do follow up the links if you're interested in knowing what all those lines mean)
3. Now, do a
locate php.ini
and open up the /etc/php5/apache2/php.ini file and add
extension=mongo.so
to the file, and that's it.
DONE !
Now, restart the apache server by executing
sudo service apache2 restart
And voila !