Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 8 - Install MongoDB

Using Debian's Packages

sudo apt-get update
sudo apt-get install mongodb-server -y

This will result in you installing a shell and server of version 2.4.10

Using MongoDB's Apt Repository

This method allows your system to receive the latest stable version of MongoDB, but one that is deemed stable by the MongoDB team, not the Debian team.

First add their key so your system recognizes mongoDBs signed packages and trusts them.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Now add their repository to your sources. If you want to remove this later, just delete the file /etc/apt/sources.list.d/mongodb-org-3.0.list

echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

Now install the packages

sudo apt-get update
sudo apt-get install mongodb-org -y

This will result in you installing a shell and server of version 3.0.7

Extra Commands

Start the service

sudo service mongodb start

Check the Version

To check the version you first need to enter the mongoDB shell

mongo

This will tell you the shell version upon entry.

Then to find the verson of the server you just enter the command:

db.version()

Conclusion

We now have mongoDB installed on our Debian 8 server. Now we may want to install a MongoDB PHP Driver in order to use it.

References

Last updated: 9th January 2023
First published: 16th August 2018