MongoDB is a free and open-source cross-platform document-driven NoSQL database program. Instead of using tables and rows as in traditional relational databases, MongoDB makes use of collections and documents. Documents consist of key-value pairs which are the basic unit of data in MongoDB.
This article covers how to install MongoDB on a VPS or dedicated server.
Related Article
SSH into VPS or Dedicated Servers
Installing MongoDB Service
IMPORTANT: Please be aware that while Technical Support can install MongoDB, they cannot provide further support on this issue or assistance with custom configurations as it is out of scope (OOS). It is strongly advised that a third-party developer assists with MongoDB.
IMPORTANT: This solution will require root access. If this needs to be obtained, follow the guide on requesting root access.
- SSH into the server as root
- Create the file
/etc/yum.repos.d/mongodb-org.repo
using nano or another text editor
EXAMPLE:
nano /etc/yum.repos.d/mongodb-org.repo
- Add the following to the file
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc - Save the file
TIP: On nano, you can save and exit the file using <Ctrl+X>. - Install MongoDB
yum install -y mongodb-org
- Start the MongoDB service
service mongod start
Install the MongoDB PHP Extension
- Install the extension using PECL
/opt/cpanel/ea-phpXX/root/usr/bin/pecl install mongodb
REPLACE: XX with the correct PHP version (eg. 74 for 7.4).
TIP: The following one-liner can be used to install the MongoDB PECL extension on all versions of PHP up to 8.2, if available.
for i in 56 70 71 72 73 74 80 81 82; do /opt/cpanel/ea-php$i/root/usr/bin/pecl install mongodb; done
Uninstalling MongoDB
- Run the following to remove all PECL extensions
for i in 56 70 71 72 73 74 80 81 82; do /opt/cpanel/ea-php$i/root/usr/bin/pecl uninstall mongodb; done
- Stop the service
service mongod stop
- Run the following to uninstall MongoDB
yum -y remove mongodb-org mongodb-database-tools mongodb-mongosh mongodb-org-database mongodb-org-database-tools-extra mongodb-org-mongos mongodb-org-server mongodb-org-tools
This article covers MongoDB 6.0. If an updated version is available and not documented here, drop us a comment so we can work to get it updated for you as soon as possible!
Comments
0 comments
Article is closed for comments.