Nextcloud on a VPS (2026): Private Cloud Done Right

Published on | Updated

Set up Nextcloud on a VPS the way its admin manual describes: All-in-One, Docker Compose with Caddy or a manual install on Ubuntu 24.04, plus caching, cron, backups, updates and sizing the disk.

A data center aisle with server racks on both sides and a technician holding a tablet

Quick Answer: Nextcloud's admin manual names Nextcloud All-in-One (AIO) as the official install method: one Docker command starts a mastercontainer, and its web interface sets up Nextcloud with PostgreSQL, Redis and APCu, plus optional extras such as Nextcloud Office and a backup tool. The community Docker image, the Snap package and a manual install from the .tar archive are the main alternatives; this guide shows AIO, a Docker Compose stack with Caddy, and a manual install on Ubuntu 24.04. Whichever route you take, serve it over HTTPS, run background jobs with cron, back up config, data and database together, and size the VPS by disk first, because your files, their old versions and their previews all live on it.

Nextcloud is a private cloud for files, photos, and calendar sync. A VPS gives you full root access, so you choose the install method, the database and the backup routine yourself.

Table of Contents

  1. Why Nextcloud
  2. VPS requirements
  3. Install overview
  4. Performance tips
  5. Sync clients and apps
  6. Backups and updates
  7. Security essentials
  8. Related guides

1. Why Nextcloud

Own your data with a modern web UI and mobile apps. Nextcloud Server is open source under the AGPL-3.0, so there is no licence fee for the server itself, and your files stay in the data center you picked, under your rules.

Google DriveDropboxYour Nextcloud
Free storageUp to 15 GB, shared with Gmail and Google Photos2 GB (Basic)None: you pay for the VPS
More storageA Google One planPlus: 2 TB for one personA bigger VPS disk or extra storage
Who runs the serverGoogleDropboxYou

We checked both on their own pages on 26 November 2026; see Google's storage help and Dropbox's plans for current prices.

Besides files, Nextcloud apps add calendar and contacts (CalDAV and CardDAV), notes, Deck boards and Talk for chat and video calls. Document editing works through Nextcloud Office or Collabora Online, which you set up on top. For sensitive folders, the End-to-End Encryption app encrypts files on your device before they reach the server.

2. VPS requirements

From the system requirements in the Nextcloud 35 admin manual:

  • A 64-bit CPU, OS and PHP (strongly recommended)
  • PHP 8.3, 8.4 or 8.5 (8.5 recommended) if you install without containers
  • A database: MariaDB 10.11, 11.4, 11.8 or 12.3 (12.3 recommended), MySQL 8.4 or 9.7, or PostgreSQL 14 to 18 (18 recommended); SQLite only for testing and minimal instances
  • Memory: at least 128 MB per PHP process and 512 MB per process recommended; what you really need depends on the number of users, apps, files and activity

You also need a domain or subdomain with an A record (and an AAAA record for IPv6) pointing at the VPS, and ports 80 and 443 open. The AIO README adds that Docker works best on a KVM based VPS and that SSD storage is recommended. Plan backups from day one: backups are not included in the plan price of a Space-Node VPS, but you can arrange them through a support ticket, or run your own as in section 6.

3. Install overview

The Installation on Linux page of Nextcloud's admin manual lists these routes (it also names the Nextcloud VM appliance and NextcloudPi):

  1. Nextcloud All-in-One (AIO), the official method. It runs in Docker and includes Nextcloud, Redis and APCu, PostgreSQL and optional extras such as Nextcloud Office, the high performance backend for Talk and a BorgBackup based backup. AIO is free for up to 100 users; more need Nextcloud Enterprise.
  2. The community Docker image, in an Apache or an FPM variant, for a stack where you bring the database, Redis and a reverse proxy yourself. Its README says volunteers maintain it and that it is designed for expert use. The Compose stack below uses it.
  3. The community Snap package, which maintains its HTTPS certificates and updates itself.
  4. A manual install from the .tar archive on Apache, MariaDB and PHP, which the manual walks through on Ubuntu 24.04. A condensed version follows below.

The manual notes that the community options are not officially supported by Nextcloud GmbH.

AIO in four steps

  1. Install Docker Engine from Docker's own packages. The AIO README does not support Docker installed as a snap.
  2. Start the mastercontainer with the command from the AIO README:
sudo docker run \
  --init \
  --sig-proxy=false \
  --name nextcloud-aio-mastercontainer \
  --restart always \
  --publish 80:80 \
  --publish 8080:8080 \
  --publish 8443:8443 \
  --volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
  --volume /var/run/docker.sock:/var/run/docker.sock:ro \
  ghcr.io/nextcloud-releases/all-in-one:latest
  1. Open https://<your-server-ip>:8080 by IP address, not by domain, and accept the self-signed certificate. Enter your domain there: AIO needs a real domain that already points at the server (it does not work with an IP address or self-signed certificates for Nextcloud) and validates it before it starts the containers.
  2. Open 443/TCP in your firewall for Nextcloud (the AIO README lists it as mandatory), plus 443/UDP for HTTP/3 and 3478 TCP and UDP if you enable Talk. Port 8080 serves the AIO interface with a self-signed certificate; port 80 redirects to Nextcloud and, together with 8443, gives the AIO interface a valid certificate.

For production, the AIO README suggests its example Compose file over docker run. If a web server or reverse proxy already runs on the VPS, follow AIO's reverse proxy documentation instead of this command.

The community Docker image with Compose and Caddy

This stack runs five containers: the community nextcloud image, MariaDB 11.8, Redis, a cron container for background jobs and Caddy, which gets and renews the HTTPS certificate on its own. Install Docker Engine and the Compose plugin from Docker's own packages and run the docker commands with sudo unless your user is in the docker group.

Make a folder, for example ~/nextcloud, and create a .env file in it with your own long random passwords. Compose reads this file from the project folder and fills in the ${...} values:

MYSQL_ROOT_PASSWORD=change-this-root-password
MYSQL_PASSWORD=change-this-database-password
NEXTCLOUD_ADMIN_USER=admin
NEXTCLOUD_ADMIN_PASSWORD=change-this-admin-password

Then create compose.yaml in the same folder and replace cloud.example.com with your domain:

services:
  nextcloud:
    image: nextcloud:stable
    restart: unless-stopped
    volumes:
      - nextcloud_data:/var/www/html
    environment:
      - MYSQL_HOST=db
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER}
      - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD}
      - NEXTCLOUD_TRUSTED_DOMAINS=cloud.example.com
      - REDIS_HOST=redis
      - APACHE_DISABLE_REWRITE_IP=1
      - TRUSTED_PROXIES=172.28.0.0/16
      - OVERWRITEPROTOCOL=https
      - OVERWRITECLIURL=https://cloud.example.com
    depends_on:
      - db
      - redis

  cron:
    image: nextcloud:stable
    restart: unless-stopped
    volumes:
      - nextcloud_data:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

  db:
    image: mariadb:11.8
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED
    volumes:
      - db_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}

  redis:
    image: redis:7-alpine
    restart: unless-stopped

  caddy:
    image: caddy:2
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    volumes:
      - ./conf:/etc/caddy
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      - nextcloud

networks:
  default:
    ipam:
      config:
        - subnet: 172.28.0.0/16

volumes:
  nextcloud_data:
  db_data:
  caddy_data:
  caddy_config:

What the less obvious lines do:

  • nextcloud:stable: on 26 November 2026 this tag points to Nextcloud 34.0.6 (Apache variant), while latest points to 35.0.3. Both work with this file; pick one and stay on it.
  • mariadb:11.8: a MariaDB version that both tags support. The Nextcloud 34 manual (the stable tag) marks 11.8 as recommended and does not list 12.3; the Nextcloud 35 manual recommends 12.3 and supports 11.8 too. Do not use mariadb:latest: it points to MariaDB 13, which neither manual lists. The --transaction-isolation=READ-COMMITTED flag is the one Nextcloud's own Compose example passes to MariaDB.
  • NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD: with these and the database variables set, the install runs on first start and skips the web-based setup wizard, so no setup page waits on a public URL for whoever opens it first.
  • TRUSTED_PROXIES, APACHE_DISABLE_REWRITE_IP, OVERWRITEPROTOCOL and OVERWRITECLIURL: these tell Nextcloud that Caddy is a trusted proxy and that the public URL uses HTTPS. The manual's reverse proxy page says you must name the proxies Nextcloud may trust.
  • networks: pins the Compose network to 172.28.0.0/16, a private range, so the trusted proxy range is known before the first start. If another Docker network on your server already uses that range, pick another private range and change both lines.
  • No ports on the nextcloud service: only Caddy is reachable from outside. Compose puts all services on one network where they find each other by service name, so Caddy reaches Nextcloud at nextcloud:80.

Caddy gets a certificate from a public ACME CA such as Let's Encrypt or ZeroSSL, keeps it renewed and redirects HTTP to HTTPS, as long as the domain's A/AAAA records point to the server, ports 80 and 443 are reachable and its data folder is persistent (the caddy_data volume). Create conf/Caddyfile next to compose.yaml, again with your own domain in the first line:

cloud.example.com {
    header Strict-Transport-Security "max-age=15552000; includeSubDomains"
    redir /.well-known/carddav /remote.php/dav/ 301
    redir /.well-known/caldav /remote.php/dav/ 301
    reverse_proxy nextcloud:80
}

The two redir lines come from Nextcloud's reverse proxy documentation, which recommends that the proxy does these redirects so calendar and contact apps find the endpoints. The HSTS header uses the value from Nextcloud's hardening guide. Start the stack from the project folder with docker compose up -d, then open https://cloud.example.com and log in with the admin account from your .env file.

If you prefer PostgreSQL, the image takes POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD and POSTGRES_HOST instead of the MySQL variables. If you put Nginx Proxy Manager in front instead of Caddy, the manual's reverse proxy page says to add proxy_hide_header Upgrade; under Custom Nginx Configuration in the proxy host's Advanced settings, otherwise iPhones and iPads get a "Connection Closed" error.

A manual install on Ubuntu 24.04

This follows the manual's example installation for Ubuntu 24.04 LTS (Ubuntu is one of the Linux images in Space-Node's VPS order form). Ubuntu 24.04 ships PHP 8.3 and MariaDB 10.11, both on Nextcloud 35's supported lists.

Install the packages. Up to php-zip this is the manual's list; php-apcu, php-redis and redis-server are for caching and bzip2 unpacks the download:

sudo apt update && sudo apt upgrade
sudo apt install apache2 mariadb-server libapache2-mod-php php-gd php-mysql \
  php-curl php-mbstring php-intl php-gmp php-xml php-imagick php-zip \
  php-apcu php-redis redis-server bzip2

Create the database and its user with sudo mysql:

CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'your-strong-password';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
quit;

Nextcloud uses the READ COMMITTED transaction isolation level. Add these lines to /etc/mysql/my.cnf and restart MariaDB with sudo systemctl restart mariadb:

[mysqld]
transaction_isolation = READ-COMMITTED
binlog_format = ROW

Download Nextcloud, check the checksum (the command must print latest.tar.bz2: OK), unpack it and hand it to the web server user:

cd /var/www/
sudo wget https://download.nextcloud.com/server/releases/latest.tar.bz2
sudo wget https://download.nextcloud.com/server/releases/latest.tar.bz2.sha256
sha256sum -c --ignore-missing latest.tar.bz2.sha256
sudo tar -xjf latest.tar.bz2
sudo chown -R www-data:www-data /var/www/nextcloud

Create /etc/apache2/sites-available/nextcloud.conf for plain HTTP on port 80; Certbot adds HTTPS in the next step:

<VirtualHost *:80>
    DocumentRoot /var/www/nextcloud/
    ServerName cloud.yourdomain.com

    <Directory /var/www/nextcloud/>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews

        <IfModule mod_dav.c>
            Dav off
        </IfModule>
    </Directory>
</VirtualHost>

Enable the site and the modules the manual lists for Apache with mod_php, then get the certificate. Let's Encrypt checks your domain over port 80, so the DNS record must already point at the VPS:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d cloud.yourdomain.com

Visit https://cloud.yourdomain.com and complete the web installer: create the admin account, then open Storage & database and enter the database user, password and name from above, with localhost as the host. The same section sets the data folder. The manual advises choosing it at installation, because it is difficult to move afterwards; read our Nextcloud storage planning guide first.

4. Performance tips

Caching: use APCu for the local cache and Redis for the distributed cache and file locking, which is what the manual recommends for a single server (Redis for both if you are short on memory). AIO includes both. The community image uses APCu out of the box and configures Redis when you pass REDIS_HOST, as the Compose file above does. On a manual install, add this inside the $CONFIG array of config/config.php:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
    'host' => 'localhost',
    'port' => 6379,
],

The manual warns that the Redis server may not start on its own; sudo systemctl enable --now redis-server starts it and keeps it on after a reboot.

  • PHP memory: the manual says memory_limit should be at least 512 MB. In the community image it comes from the PHP_MEMORY_LIMIT variable, which defaults to 512M, and PHP_UPLOAD_LIMIT (also 512M) sets the upload limits. On a manual install, set it in /etc/php/8.3/apache2/php.ini and raise apc.shm_size to 128M there too: the manual calls the 32M default usually too low for Nextcloud. Restart Apache afterwards.
  • Background jobs: switch from the default AJAX mode to cron every 5 minutes, as the manual recommends. In the Compose stack the cron container does this; keep its volumes identical to the nextcloud service. On a manual install, run sudo crontab -u www-data -e and add */5 * * * * php -f /var/www/nextcloud/cron.php. Once cron has run cron.php, Nextcloud switches its background jobs setting to Cron by itself.
  • PHP-FPM: on setups that use PHP-FPM (Nginx, the FPM image, or Apache with php-fpm), raise pm.max_children from the default of 5. The manual sizes it as the RAM you can give PHP divided by the average worker size, which it puts at 50 to 100 MB for a typical worker, and asks you to leave room for the OS, web server, database and cache.
  • Log level: keep loglevel at 2 (WARN), the default for new installs. DEBUG (0) outputs a lot of information and can affect server performance if it stays on after troubleshooting.

The community image merges several config files, so check the result with occ instead of reading config.php:

docker compose exec -u www-data nextcloud php occ config:list system

5. Sync clients and apps

Nextcloud has official clients for:

  • Desktop: Windows, macOS and Linux (AppImage); pick folders on your computer and they stay in sync
  • Mobile: Android and iOS apps for file access and sync, which can upload new photos and videos from your phone on their own
  • WebDAV: Nextcloud has its own built-in WebDAV server, so WebDAV clients and tools such as rclone can connect

Turn on automatic upload in the mobile app and new photos and videos go straight to your own server. From the app store, Calendar, Contacts, Notes, Talk, Deck and Bookmarks cover most of what people move over from Google or Dropbox; check an app's page for the Nextcloud versions it supports before you install it.

6. Backups and updates

The manual's backup list has five parts: the config folder, the data folder, the theme folder, the custom apps folder if you installed custom apps, and the database. Put Nextcloud in maintenance mode first (occ maintenance:mode --on, and --off afterwards; in the Compose stack, docker compose exec -u www-data nextcloud php occ maintenance:mode --on) so the files and the database dump match. The manual gives the dump commands, for example mariadb-dump --single-transaction for MariaDB and pg_dump for PostgreSQL. AIO has its own BorgBackup based backup, which can run daily and then update the containers, Nextcloud and its apps. Keep copies outside the VPS and test a restore now and then, so you know it works.

Updates depend on the install method: AIO updates from its interface, the community image with docker compose pull and then docker compose up -d, and a tarball install with the built-in updater. In every case you cannot skip a major version: first update to the latest point release of your current major version, then go up one major version at a time. With the community image that means stepping through each major tag if you fall behind, for example 34-apache, then 35-apache.

7. Security essentials

Serve Nextcloud over HTTPS only, redirect HTTP to HTTPS and add the HSTS header from the manual's hardening guide. Set strong admin passwords and turn on two-factor authentication: the TOTP provider ships with Nextcloud but is disabled by default (enable it under Apps, Disabled apps), and an admin can enforce 2FA for all users or for selected groups. If your admins work from known networks, allowed_admin_ranges in config.php restricts admin actions to those IP ranges. Keep containers and apt packages up to date.

Allow only SSH, HTTP on port 80 and HTTPS on 443 (plus 443/UDP for HTTP/3) in your firewall. With Docker, remember that published container ports bypass ufw rules, so publish only the ports you want public, as the Compose file above does with Caddy. Leave server-side encryption off unless you add external storage: the manual says it is mainly meant for files on external storage and does not protect data from a compromised server, and losing the keys means losing the files.

Common Questions

How much storage can I get with Nextcloud on a VPS? As much as your VPS disk holds, minus the room Nextcloud needs for old versions, deleted files and previews. Space-Node VPS plans come with 60 to 300 GB of NVMe storage on Standard and 20 to 240 GB on Premium. Every Premium plan offers extra NVMe storage in the order form (+50 GB for €6.25 or +100 GB for €12.50 a month on 26 November 2026); for more storage on Standard, ask support before ordering. For bigger libraries, Nextcloud can connect an Amazon S3 or S3-compatible bucket as external storage, or use object storage as primary storage, in which case the files are only reachable through Nextcloud. Our Nextcloud storage planning guide shows how to cap versions and deleted files and when external storage fits.

Is Nextcloud faster than Google Drive or Dropbox? We have not measured it, so there is no honest number to give. How fast it feels depends on your own connection, the distance to the data center, the VPS size and the caching setup. Set up APCu, Redis and cron first, then test with your real files before you move everything.

Can multiple users access the same Nextcloud instance? Yes. An admin creates accounts on the User management page and can set a default storage quota plus a quota per user. Users share files and folders with other users, groups, Talk conversations or public links; on internal shares the rights are adjustable, including whether the other person may reshare. How many users one VPS can serve depends on its RAM, CPU and tuning, so start with your own group and watch memory use as it grows. With AIO, up to 100 users are free.

How do I migrate from Google Drive to Nextcloud? For a small library, export it with Google Takeout as .zip or .tgz archives (a big export is split into several archives), unpack them on your computer and let the desktop client upload the folder. For a big library, run rclone on the VPS and copy from a Google Drive remote to a WebDAV remote with the vendor set to nextcloud, using an app password if you use two-factor authentication. rclone exports Google Docs files as docx, xlsx, pptx and svg by default. On a server without a browser, answer N to rclone's browser question during rclone config and finish the login with rclone authorize on your own computer. rclone's shared Google Drive client ID is being retired during 2026, so create your own client ID first. If you copy files straight into Nextcloud's data directory instead, run occ files:scan so Nextcloud sees them.

Should I use All-in-One, Docker Compose or a manual install? AIO if you want the route Nextcloud itself supports, with backups and updates from one interface. The Compose stack if you want to see and control each container. The manual install if you would rather not run Docker at all. All three need the same backups, cron and HTTPS.

What happens if my VPS goes down? Nextcloud is offline until the VPS is back. Keep backups of the config, data and theme folders, any custom apps and the database somewhere other than the VPS, so you can restore on a new server if you have to. A setup spread over several servers with a load balancer and shared storage is a much larger project; the admin manual points enterprises to Nextcloud's customer portal for those deployment recommendations.

8. Related guides

Sources

Opened on 31 October 2026; the system requirements, the image tags, the AIO README and the Space-Node pages were checked again on 26 November 2026: