All posts

Blog

How to Self-Host Nextcloud on a VPS: Your Own Private Cloud Storage

Illustrated cover for the Servers & VPS guide "How to Self-Host Nextcloud on a VPS: Your Own Private Cloud Storage"

Paying a monthly fee to store your files on someone else's servers is the default for most people. It works, but you don't control where your data lives, how it's scanned, or what happens if the service changes its terms. Nextcloud is the most popular open-source alternative: file sync and sharing, calendars, contacts, notes and more, all running on a server you own.

This guide shows how to self-host Nextcloud on a VPS using the official Snap package, which bundles everything Nextcloud needs into one install. We'll also cover the other installation methods so you can choose the right one for you.

Why self-host Nextcloud?

  • Ownership: your files sit on your server, under your control.
  • One place for everything: files, calendar (CalDAV), contacts (CardDAV), photo uploads from your phone and shared folders for family or a small team.
  • Desktop and mobile apps: official sync clients exist for Windows, macOS, Linux, Android and iOS.
  • Extensible: the built-in app store adds tools like office document editing, task lists and video calls.

The trade-off is responsibility. You handle updates, backups and security. If that sounds manageable, read on.

Choosing an install method

There are three common ways to run Nextcloud on a VPS:

  1. Snap package. One command installs Nextcloud with its own web server, PHP, database and caching. Updates happen automatically. Best for beginners and personal use.
  2. Nextcloud All-in-One (Docker). The officially recommended Docker setup. A master container manages the rest and offers a web interface for backups and updates. A good choice if you already use Docker (see our Docker on a VPS guide).
  3. Manual install on a LAMP or LEMP stack. Maximum control, maximum maintenance. Worth it only if you need custom tuning.

We'll use the Snap method here because it's the quickest to get right.

What you need

  • A VPS running Ubuntu 22.04 or 24.04 with at least 2 GB of RAM
  • Enough disk space for your files. Storage is usually the deciding factor for Nextcloud, so size your plan around how much data you'll keep, plus room to grow
  • A domain or subdomain, such as cloud.yourdomain.com, with an A record pointing to your VPS's IP address
  • Ports 80 and 443 free (don't install another web server on the same VPS for this setup)

Step 1: Prepare the server

Update the system and open the web ports in your firewall:

sudo apt update && sudo apt upgrade -y
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Snap comes preinstalled on Ubuntu Server. You can confirm with snap version.

Step 2: Install Nextcloud

sudo snap install nextcloud

This pulls down the latest stable Nextcloud along with Apache, PHP, MySQL and Redis, all packaged inside the snap. It takes a minute or two.

Step 3: Create the admin account

You can create the admin account in the browser, but doing it from the command line avoids leaving an open setup page on the internet:

sudo nextcloud.manual-install yourusername 'a-long-unique-password'

Pick a strong password and store it in a password manager. Using single quotes prevents your shell from interpreting special characters.

Step 4: Add your domain as a trusted domain

Nextcloud only answers requests for domains it trusts. By default, that's just localhost. Add your domain:

sudo nextcloud.occ config:system:set trusted_domains 1 --value=cloud.yourdomain.com

occ is Nextcloud's command-line admin tool, and in the snap it's available as nextcloud.occ. You can check the result with:

sudo nextcloud.occ config:system:get trusted_domains

Step 5: Turn on HTTPS

Never run a file server over plain HTTP. The snap includes a helper that requests a free Let's Encrypt certificate and renews it automatically:

sudo nextcloud.enable-https lets-encrypt

It will ask you to confirm that ports 80 and 443 are open and that your domain points at the server, then prompt for an email address and the domain name. When it finishes, visit https://cloud.yourdomain.com and log in with the admin account you created.

Step 6: Finish the setup in the browser

Once you're logged in:

  • Open Administration settings > Overview. Nextcloud runs a set of security and setup checks here and tells you about anything it doesn't like. Work through the warnings it lists.
  • Set up email under Basic settings so password resets and share notifications work.
  • Create regular user accounts for yourself and anyone else, and use the admin account only for administration.
  • Enable two-factor authentication from the apps page (the TOTP app works with any authenticator app).

Step 7: Connect your devices

Install the Nextcloud desktop client and point it at https://cloud.yourdomain.com. Choose which folders to sync and it behaves much like other sync services. On your phone, the mobile app can automatically upload photos and videos, which makes a handy replacement for commercial photo backup.

For calendars and contacts, Nextcloud provides CalDAV and CardDAV addresses under Calendar > Settings and Contacts > Settings. Most calendar and contact apps can subscribe to them directly.

Keeping Nextcloud healthy

Updates

The snap updates itself automatically, including major Nextcloud releases once they've been tested for the snap. You can see the installed version with snap list nextcloud. If you'd rather control timing, snap supports scheduling refresh windows with snap set system refresh.timer.

Backups

Your Nextcloud server is now the home of important files, so treat backups seriously. The snap includes an export tool:

sudo nextcloud.export

This creates a backup of the configuration, database and data under /var/snap/nextcloud/common/backups. Copy those backups to a different machine or storage service; a backup that lives on the same VPS won't help if the VPS itself fails. There's a matching nextcloud.import command to restore.

Storage growth

Keep an eye on disk usage, especially if several people upload photos. Our guide to monitoring server resources on a Linux VPS covers checking disk space with df -h and finding large folders with du. You can also set per-user storage quotas in Nextcloud's user management screen.

Security habits

  • Keep your VPS's operating system patched with regular apt upgrade runs.
  • Use SSH keys for server access rather than passwords.
  • Enable brute-force protection (it's on by default) and two-factor login for every account.
  • Only install Nextcloud apps you actually need, since each one adds code to maintain.

Common problems

  • "Access through untrusted domain": the domain you're using isn't in trusted_domains. Repeat step 4 with the exact hostname shown in your browser.
  • Let's Encrypt fails: the DNS record isn't pointing at the server yet, or port 80 is blocked by a firewall at the provider level.
  • Uploads stop at a certain size: large uploads through a slow connection may time out. The desktop client handles big files more reliably than the browser because it uploads in chunks.

Wrapping up

Self-hosting Nextcloud on a VPS gives you private cloud storage, calendar and contacts without handing your data to a big platform. With the Snap package, the core setup is five commands: install, create an admin, trust your domain, enable HTTPS and log in. Spend the time you saved on a solid off-site backup routine, and you'll have a personal cloud you can rely on.