MongoDB is a powerful NoSQL database used widely in modern web and mobile applications. Installing it on an Ubuntu VPS takes just a few minutes if you follow the right steps.
Step 1 — Import the public key: curl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor
Step 2 — Add the MongoDB repository: echo "deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
Step 3 — Install: sudo apt update && sudo apt install -y mongodb-org. Then enable and start the service with sudo systemctl enable --now mongod.
Step 4 — Secure your installation: enable authentication in /etc/mongod.conf, create an admin user, configure your firewall (ufw), and bind only to private IPs in production.
Once running, you can connect via mongosh or your preferred MongoDB client. For high-traffic production workloads, consider replica sets and managed backups.