Page 1 of 1

[HowTo] Install MongoDB 4.0 on VestaCP with Centos 7/RHEL 7

Posted: Tue Sep 11, 2018 6:59 pm
by xorro
Step 1

Adding MongoDB 4.0 Repository :

Create repo file :

Code: Select all

yum install nano -y
nano /etc/yum.repos.d/mongodb4.repo
Now add this lines to mongodb4.repo :

Code: Select all

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
Save and exit

Step 2

Installing MongoDB 4.0 :

Code: Select all

yum install -y mongodb-org
If you’ve enabled selinux you need to run this command in order to give access :

Code: Select all

semanage port -a -t mongod_port_t -p tcp 27017
*use this command if you’re using enforcing mode

Step 3

Verify the installation and enable startup :

Start MongoDB Service :

Code: Select all

service mongod start
To restart and stop MongoDB Service :

Code: Select all

service mongod restart
service mongod stop
you need to run this command from command line in order to access mongo db CLI interface :

Code: Select all

mongo
To enable mogodb start automatically during os boot :

Code: Select all

systemctl enable mongod