Debian 8 - Install MongoDB
Using Debian's Packages
sudo apt-get update
sudo apt-get install mongodb-server -y
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
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
First published: 16th August 2018