CloudLinux.ro
Applications

How to install MongoDB on a Cloud VPS

Updated 7/18/2026

MongoDB is the popular document database for flexible, JSON-like data models, powering modern applications at any scale.

A database on your own server gives you low latency and full control over configuration and backups, without managed-service pricing.

One-click install on cloudlinux.ro

The fastest way: MongoDB installs automatically at the first boot of a new server.

  1. Create a Cloud VPS from the control panel.
  2. In the configuration step, pick MongoDB from the app catalog.
  3. Start the server. The install runs in the background for a few minutes and its status shows on the server page.
  4. Access details and generated passwords are saved on the server in /root/app-credentials.txt. The app will be available on port 27017.

Manual install on any Ubuntu server

If you prefer doing it yourself, below is the exact script our automatic install runs. Execute it as root on a fresh Ubuntu server (24.04 recommended). It stops at the first error, and when it finishes you will find the access details in /root/app-credentials.txt.

export DEBIAN_FRONTEND=noninteractive
curl -fsSL https://get.docker.com | sh
DB_PASS=$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | cut -c1-20)
docker volume create mongo_data
docker run -d --name mongodb --restart=always -p 27017:27017 \
  -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD="$DB_PASS" \
  -v mongo_data:/data/db mongo:7
IP=$(hostname -I | awk '{print $1}')
printf 'MongoDB: %s:27017\nUtilizator: admin\nParola: %s\nPortul este public, foloseste parola generata si restrictioneaza accesul daca nu ai nevoie de conexiuni externe.\n' "$IP" "$DB_PASS" > /root/app-credentials.txt

You can also save this script as a recipe in your account and reuse it on any new server.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials