📑 Contents ▾
A VPS is a good home for Nextcloud if you want a fixed IP address, a datacenter connection and no hardware to look after. It is a much weaker choice for storing large volumes: VPS disk space is paid for every month, and it pushes the bill up long before the CPU does. For one to three people, 2 to 4 GB of RAM is enough, as long as the files live on a separate volume and the backups leave the machine. Nextcloud AIO is still the simplest install, with one VPS-specific precaution: Docker opens its ports without going through ufw.
This page installs AIO on its own on the VPS, with no reverse proxy in front of it: AIO’s own Apache container answers on port 443. It covers what is specific to a VPS: sizing, a separate storage volume, Docker ports and ufw, and backups that leave the machine. If you already run a reverse proxy (Caddy, Traefik, Nginx Proxy Manager) in front of your services, follow our Nextcloud AIO tutorial with Docker Compose behind Caddy instead.
VPS or home server: what changes for Nextcloud
What the VPS gives you
- A fixed IP and symmetric bandwidth. A home connection often has a dynamic IP and variable latency, which you notice when a phone or a sync client uploads files from outside.
- No hardware at home. No disk to replace and no power cut to deal with: the physical machine is the provider’s problem.
- A service isolated from your home network. If the instance is compromised, the intruder is on the VPS, not on your local network.
- Disk snapshots, offered by most providers, handy right before an update.
What it costs you
- Disk space. A VPS system disk is sized for the system, not for hundreds of GB of photos. Beyond that, you rent an extra storage volume (block storage), billed by capacity.
- Trust in the provider, who has physical access to the machine and its disks.
- A subscription, where a mini PC or a NAS already running at home only costs its electricity.
A Raspberry Pi 5 is fine for light personal use, but Nextcloud does a huge number of small reads and writes (database, thumbnails, sync): a micro-SD card, and even a USB-attached SSD, hit their limits quickly.
How big a VPS
| Use | Active users | Planned files | RAM | vCPU |
|---|---|---|---|---|
| Solo or small family | 1 to 3 | under 500 GB | 2 to 4 GB | 1 to 2 |
| Small team, heavy use | 5 to 20 | 1 to 5 TB | 4 to 8 GB | 2 to 4 |
| Organization, heavy collaboration | over 20 | over 5 TB | 8 to 16 GB and up | 4 and up |
These ranges are indicative, not measurements made by Selfhostr. What moves them:
- RAM. AIO runs several containers: Nextcloud (PHP), PostgreSQL, Redis and Apache, plus the ones you enable (Collabora or OnlyOffice for documents, Talk for video calls, the ClamAV antivirus, full-text search). 2 GB is a floor; 4 GB keeps the system from swapping, which slows everything down. Each optional service adds its share: only enable the ones you will use.
- CPU. It mostly works on photo thumbnails and online document editing.
- Storage. Do not leave user files on the system disk. Mount a separate volume, for example on
/mnt/ncdata, and give it to AIO at the very first install (see below). The volume outlives the virtual machine, which makes backups and moving to another VPS simpler.
Installing Nextcloud AIO on the VPS
Nextcloud AIO (All-in-One) is the Docker method maintained by the Nextcloud project: a master container downloads, configures and updates all the others. You do not manage the database or the cache by hand.
Prerequisites
- A VPS running Ubuntu 24.04 LTS or Debian stable, with
sudoaccess. - A domain name whose DNS record points to the VPS IP (for example
cloud.yourdomain.com). - Port 443 reachable from the Internet: according to its documentation, AIO checks the domain before starting, then its Apache container obtains the Let’s Encrypt HTTPS certificate on its own.
- The storage volume rented from the provider, mounted on
/mnt/ncdata(each provider documents how to mount its volumes). Check withdf -h /mnt/ncdata.
Step 1: install Docker
On Debian, connect over SSH and run:
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
On Ubuntu, replace linux/debian with linux/ubuntu in both URLs: the Debian repository does not know Ubuntu’s release names.
Step 2: start the master container
sudo docker run \
--init \
--sig-proxy=false \
--name nextcloud-aio-mastercontainer \
--restart always \
--publish 127.0.0.1:8080:8080 \
--env NEXTCLOUD_DATADIR="/mnt/ncdata" \
--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
This command is based on the one in the official Nextcloud AIO documentation (the README of the nextcloud/all-in-one repository on GitHub), which the points below sum up. Reread it before installing: if it has changed, it is the reference.
- The container name and the volume name cannot be changed. AIO relies on
nextcloud-aio-mastercontainerand on thenextcloud_aio_mastercontainervolume, which holds its whole configuration. NEXTCLOUD_DATADIRis set at the first install. According to the documentation, changing it later means migrating the data.--publish 127.0.0.1:8080:8080only opens the admin interface on the VPS itself; the command in the documentation publishes it on every interface. The firewall section explains why.- No port 80 here. The command in the documentation also publishes port 80 and a second port for the interface: they are used to reach the admin interface through the domain, with a valid certificate. With the SSH tunnel below, you do not need them. Nextcloud itself is served over HTTPS by AIO’s Apache container, on port 443.
--sig-proxy=false: according to the documentation, Ctrl+C then closes the log output without stopping the container.
Step 3: finish the setup in the AIO interface
Since the interface only listens on the VPS, go through an SSH tunnel from your computer:
ssh -L 8080:127.0.0.1:8080 user@VPS_IP
Then open https://localhost:8080. The certificate is self-signed: the browser warning is expected. The steps below are the ones the AIO documentation describes:
- Write down the passphrase shown on screen. It is what unlocks the AIO interface; keep it in a password manager.
- Enter your domain. AIO checks that it points to the server and that port 443 answers.
- Pick the optional services (office suite, Talk, antivirus, full-text search) with the VPS RAM in mind.
- Start downloading and launching the containers. AIO then shows the initial username and password of the Nextcloud admin account: write them down.
Step 4: the settings that matter
PHP upload size, run time and memory. According to the Nextcloud AIO documentation, these limits are not set in a php.ini but through variables passed to the master container: NEXTCLOUD_UPLOAD_LIMIT (maximum size of an upload), NEXTCLOUD_MAX_TIME (maximum duration of an upload or a request) and NEXTCLOUD_MEMORY_LIMIT (memory given to PHP). Their default values are listed in that documentation: check them before changing anything. To change a variable, stop the containers from the AIO interface, remove the master container, then rerun the step 2 command with one more --env; the volume keeps the configuration.
sudo docker stop nextcloud-aio-mastercontainer
sudo docker rm nextcloud-aio-mastercontainer
# then the step 2 command, with for example --env NEXTCLOUD_MEMORY_LIMIT=1024M
occ commands. Nextcloud’s admin tool runs inside the nextcloud-aio-nextcloud container, as the www-data user:
sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ status
Database and cache. AIO creates PostgreSQL and Redis and configures them itself: its documentation provides no MySQL or MariaDB option, and there is nothing to tune by hand for normal use. If the “Overview” page of the administration settings shows a warning, restart the containers from the AIO interface before digging further.
Background jobs. AIO runs them through cron, with nothing to set on your side. In Administration settings > Basic settings, the background jobs section should show Cron and a recent run.
Firewall: ufw does not see ports published by Docker
This is the most common trap on a VPS. Docker writes its own iptables rules for the ports it publishes, and that traffic does not go through ufw’s input rules. A ufw deny 8080 rule therefore does not block a container published on port 8080: all that counts is where Docker publishes the port.
Hence publishing the AIO interface on 127.0.0.1 in step 2. The only port actually open to the public is then 443, published by the AIO Apache container. Since the command does not publish port 80, give your users the full https:// address. If you enable Talk, its TURN server needs one more port, listed in the AIO documentation.
ufw is still useful for everything outside Docker, starting with SSH:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 443/tcp # Nextcloud over HTTPS
sudo ufw enable
The 443 rule documents what must be open; for containers, Docker’s port publishing is what decides.
If your provider offers a network firewall, applied outside the virtual machine, it also filters ports published by Docker: only let SSH and 443 through (plus the Talk port if you enable it). For the rest of the hardening (SSH keys, a dedicated user, automatic updates), follow our guide to installing and securing an Ubuntu VPS.
Backups: the copy has to leave the VPS
According to the AIO documentation, its built-in backup is based on BorgBackup: encrypted and deduplicated, it covers the whole instance (files, database and configuration) and is set up in the AIO interface.
- Pick a destination folder on the host, ideally on a second volume (for example
/mnt/backup) rather than on the system disk. - Keep the backup password AIO shows you outside the VPS: without it, the archive cannot be read.
- Turn on the daily backup at the time of your choice. AIO can update the containers right after it, which guarantees a fresh backup before every update.
Because Borg deduplicates, every archive is a complete restore point while only the changes take up space: there is no need to combine weekly full backups with daily incrementals.
The VPS-specific point: a backup stored on the same machine, or with the same provider, does not survive losing the account or the server. Provider snapshots complement the backup, they do not replace it. Keep a copy elsewhere: either copy the Borg folder to another machine (a NAS at home, another provider) at a time when no backup is running, or run a second, independent backup with another tool to object storage. Our restic vs Borg vs Kopia comparison helps pick that second tool.
Test a restore every 3 months. On a disposable test VPS: install Docker and start the master container. On a fresh install, the AIO interface offers, according to its documentation, to restore an instance from a backup: give the archive location and its password. Check that accounts can log in and that files are intact.
If the VPS is lost, it is the same procedure on a new VPS: Docker, then the master container with the same command (same NEXTCLOUD_DATADIR), the Borg folder brought back from your off-site copy, and the restore from the AIO interface. All that is left is pointing the domain’s DNS to the new IP.
AIO or a manual install?
AIO suits most uses, from a family account to a small team: one container to watch, updates started from the interface and the built-in backup. In return, AIO imposes its own choices, PostgreSQL included, and uses a little more resources than an install without Docker.
A manual install (PHP, Apache or Nginx, MariaDB or PostgreSQL, Redis), or a hand-written Docker Compose, uses less RAM and lets you control everything. You are also the one handling every update, security and the backups.
To migrate an existing instance to AIO, the AIO documentation describes the procedure. Do a full trial run on a staging VPS before shutting down the old service, and check file ownership after the import.
Choosing the VPS provider
For Nextcloud, look less at the CPU than at storage: whether you can add a separate volume and what it costs per unit of capacity, snapshots, a network firewall outside the VM, and where the datacenter is. Our roundup of the best VPS for self-hosting goes through these points. If you are looking for a French and Canadian host, PlanetHoster offers VPS servers: See PlanetHoster plans