Installing mongoDB on Debian Squeeze (and Ubuntu).

There’s no point in me trying to sell mongoDB to you, just go over to the mongoDB site and read up on its excellence.

This is how I got mongoDB working on Debian Squeeze. It should work for other Deb based flavours – I’m thinking Ubuntu. I also have a PHP5x setup so you may need to adapt if you are running earlier versions. I’m also assuming you have git installed to fetch the drivers.

All you have to do follows:

First install the necessary mongo stuff (you need php5-dev also as we need the phpize functionality):

sudo apt-get install mongodb mongo-clients php5-dev

Now fetch the official mongoDB php driver from github:

git clone https://github.com/mongodb/mongo-php-driver.git

Change into the driver directory and run the following commands:

cd mongo-php-driver
phpize
./configure
sudo make install

Copy the driver to php extension dir. To find your extension dir run:

php -i | grep extension_dir

Armed with the location of your extension dir copy the file:

sudo cp modules/mongo.so /path/to/php/extension_dir/

Now create a file to load the driver into php at start up:

sudo vi /etc/php5/conf.d/mongo.ini

with the line:

extension=mongo.so

Now restart apache:

sudo /etc/init.d/apache2 restart

Then start an instance of the mongo server and PHP should be mongo friendly.

If you want to test this go grab a copy of the excellent phpMoAdmin and drop the file anywhere you load it through a browser. It should connect off the bat to mongoDB and you can start creating collections and objects in less time than it takes you to type “CREATE TABLE …”.

Enjoy.

One thought on “Installing mongoDB on Debian Squeeze (and Ubuntu).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>