Blog / Tutorials

Self-Host Nextcloud on a VPS — Own Your Drive, Calendar and Contacts

By the NoctHost TeamJuly 10, 20264 min read

Google Drive, Dropbox and iCloud are convenient right up until you think about who else can read your files, and what happens when the subscription lapses. Nextcloud is the open-source answer: files, calendar, contacts, notes and photos on a server you control.

This guide gets you from a blank Ubuntu VPS to a working, HTTPS-secured Nextcloud in about fifteen minutes, with honest notes on how much server you actually need.

What You Need

  • A VPS with at least 2 GB RAM (4 GB is comfortable once you add the calendar, contacts and preview generation)
  • Ubuntu 22.04 or 24.04 with SSH access
  • A domain or subdomain pointed at the server's IP

Storage is the real sizing question, not CPU. Nextcloud itself is light; your files are what grow. Pick a plan by how much you plan to store, and remember you can resize later.

Step 1: Install Docker

curl -fsSL https://get.docker.com | sh

Step 2: The Compose File

This runs Nextcloud with a Postgres database and Caddy for automatic HTTPS — no manual certificate wrangling. Save it as docker-compose.yml:

services:
  db:
    image: postgres:16-alpine
    restart: always
    environment:
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: change-this-password
    volumes:
      - db:/var/lib/postgresql/data

  app:
    image: nextcloud:apache
    restart: always
    environment:
      POSTGRES_HOST: db
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: change-this-password
      NEXTCLOUD_TRUSTED_DOMAINS: cloud.example.com
    volumes:
      - nextcloud:/var/www/html
    depends_on:
      - db

  caddy:
    image: caddy:2-alpine
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
    depends_on:
      - app

volumes:
  db:
  nextcloud:
  caddy_data:

Step 3: The Caddyfile

Caddy fetches and renews a Let's Encrypt certificate for you. Create Caddyfile next to the compose file:

cloud.example.com {
  reverse_proxy app:80
}

Replace cloud.example.com with your real domain (in both files), then bring it up:

docker compose up -d

Open https://cloud.example.com and create your admin account. The certificate is issued automatically on first request.

Step 4: Lock It Down

Two settings that matter on a public server:

  1. In Settings → Administration → Security, confirm you are served over HTTPS only.
  2. Do not expose the Postgres port. In the compose above it is only reachable inside the Docker network, which is correct — never add a ports: entry to the db service.
Tip — Turn on server-side encryption only if you genuinely need it. It protects files at rest but breaks some sync/preview features and cannot be easily undone — most people are better served by full-disk encryption at the provider level.

Step 5: Back It Up

Your data lives in two Docker volumes. A nightly backup to off-site storage is a one-liner with rclone (configure a remote first with rclone config):

docker compose exec -T db pg_dump -U nextcloud nextcloud | gzip > /root/nc-db.sql.gz
docker run --rm -v nextcloud:/data -v /root:/backup alpine tar czf /backup/nc-files.tar.gz -C /data .
rclone copy /root/nc-db.sql.gz remote:nextcloud-backups
rclone copy /root/nc-files.tar.gz remote:nextcloud-backups

Drop that in a cron job and you have real disaster recovery — something the big providers never actually give you.

What It Costs

A personal Nextcloud runs fine on a small VPS; the variable is storage. On NoctHost you pay hourly from a prepaid balance, so a media-heavy instance and a light one cost exactly what they use, and you can top up with crypto without a card on file. For a household drive plus calendar and contacts, the Standard plan (2 vCPU, 4 GB) is the sweet spot.

Spin one up in about a minute

Email signup, pay with crypto, hourly billing. Trying a box costs cents — destroy it when you are done.

Deploy a server

Frequently asked

How much RAM does Nextcloud need?
2 GB works for a single user; 4 GB is comfortable once you enable preview generation, calendar and contacts. CPU is rarely the bottleneck — storage and RAM for previews are.
Can I use the mobile and desktop apps?
Yes. The official Nextcloud desktop and mobile clients connect to your server the same way they connect to a hosted one — point them at your domain and log in.
Is self-hosted Nextcloud private?
Your files stay on your server and are not scanned or used to train anyone's models. Privacy still depends on your operational hygiene: keep it updated, back it up, and use a clean dedicated IP.
What happens to my files if I stop paying?
On NoctHost a paused server keeps a snapshot for a retention window, and top-up restores it. But treat off-site backups (Step 5) as your real safety net — never rely on a single copy.

Keep reading