Install MongoDB on a CentOS VPS

mongodbMongoDB is a NoSQL document-oriented database. It is a cross-platform and it makes the process of data integration faster and much easier. Since it is free and open-source, MongoDB is used by number of websites and organizations. The installation of MongoDB on a Linux VPS is very simple and today we will show you how to do that.

We will use a CentOS VPS for this tutorial and we will start with a system update. For that purpose, you can use the following command:

yum update

Once your system is up to date, you can proceed with the other steps of the installation. We will show you how to install MongoDB on your Linux VPS using a .rpm package. Let’s add the official MongoDB repository to your system. Create a /etc/yum.repos.d/mongodb.repo file.

touch /etc/yum.repos.d/mongodb.repo

Then, using your favorite text editor, you need to edit the file. If you are using 64bit system, you need to add the following content to the /etc/yum.repos.d/mongodb.repo file:

name=MongoDB Repository

Otherwise, if you are using a 32bit system you need to add the following content:

name=MongoDB Repository

Save the file and close it. If you are done with the previous step you can use the yum package manager to install MongoDB on your CentOS VPS.

yum install mongo-10gen mongo-10gen-server

The installation should take only a few minutes and once it is over, you can start using the MongoDB. To start the service you can use:

/etc/init.d/mongod start

Also, you can stop or restart the MongoDB service by using:

/etc/init.d/mongod stop
/etc/init.d/mongod restart

The main configuration file is located in the /etc directory on your Linux VPS as mongod.conf. To edit it, you can use your favorite text editor.


To enable MongoDB on system startup, you can use the command:

chkconfig mongod on

If you like to check for errors or important messages you can watch the output in the log file:


A good way to start using MongoDB on your CentOS VPS is to read the MongoDB manual on the official website.

You can find information such as first steps, basic database operations, FAQs and much more.

Of course, you don’t have to do any of this if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install MongoDB for you. They are available 24×7 and will take care of your request immediately. For updates, you can also refer to this guide How to Install MongoDB on Ubuntu 20.04 and CentOS 8.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment

To prove you are human please solve the following *