01
Before you start
You need three things:
- A recent Linux VPS with a
sudo user: Ubuntu 24.04 or Debian 13. The current Nextcloud release requires at least PHP 8.3: Ubuntu 24.04 ships PHP 8.3 and Debian 13 PHP 8.4. Debian 12, with PHP 8.2, no longer works for a package-based install.
- A domain name, for example
cloud.example.fr, whose DNS A record points to the VPS IPv4 address. You need it to get an HTTPS certificate.
- Enough disk for your files: it often decides the plan more than the processor does. Count your files, their older versions and the trash bin.
For memory, the Nextcloud documentation states at least 128 MB per PHP process and recommends 512 MB per process. For a few users, a small VPS is enough; watch free -h during the first weeks, especially if you enable preview generation or extra apps.
Container (LXC) or virtual machine (KVM)? The package-based install works with no special setting in a container VPS. Nextcloud All-in-One runs on Docker, which works in a container with nesting enabled, but its built-in backup tool requires FUSE: read the Docker section before choosing. The differences between the two kinds of VPS are in the guide KVM or container VPS.
Start with the basic security settings (SSH key, automatic updates): the guide secure a Linux VPS gives the order to follow.
02
Method 1: install Nextcloud with packages
This method follows the Nextcloud administration manual: Apache, PHP and MariaDB from the distribution repositories, and Nextcloud from its official website. Install the packages first:
sudo apt update && sudo apt upgrade -y
sudo apt install -y 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-bcmath php-apcu bzip2 wget
Create the database and its user, with a long password you keep somewhere safe:
sudo mariadb
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'un-mot-de-passe-long';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
quit;
Download the latest release, check its checksum, then install it in /var/www:
cd /tmp
wget https://download.nextcloud.com/server/releases/latest.tar.bz2
wget https://download.nextcloud.com/server/releases/latest.tar.bz2.sha256
sha256sum -c --ignore-missing latest.tar.bz2.sha256
tar -xjf latest.tar.bz2
sudo cp -r nextcloud /var/www
sudo chown -R www-data:www-data /var/www/nextcloud
The check must answer latest.tar.bz2: OK; otherwise, delete the archive and download it again. Keep your files outside the web folder, in a separate directory: it is safer and easier to back up.
sudo mkdir -p /var/nextcloud-data
sudo chown www-data:www-data /var/nextcloud-data
Finally, run the command-line installation. It asks for the database password, then for the admin account password:
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:install --database mysql --database-name nextcloud --database-user nextcloud --admin-user admin --data-dir /var/nextcloud-data
03
HTTPS and first settings
Create the Apache virtual host in /etc/apache2/sites-available/nextcloud.conf, replacing the domain name:
<VirtualHost *:80>
DocumentRoot /var/www/nextcloud/
ServerName cloud.example.fr
<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 useful modules, then request a free Let's Encrypt certificate with Certbot, which also sets up the redirect to HTTPS:
sudo a2enmod rewrite headers env dir mime
sudo a2ensite nextcloud.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d cloud.example.fr
Then declare your domain as a trusted domain (otherwise Nextcloud refuses the connection), switch background jobs to cron and enable the APCu memory cache:
cd /var/www/nextcloud
sudo -u www-data php occ config:system:set trusted_domains 1 --value=cloud.example.fr
sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://cloud.example.fr
sudo -u www-data php occ background:cron
echo '*/5 * * * * php -f /var/www/nextcloud/cron.php' | sudo crontab -u www-data -
echo 'apc.enable_cli=1' | sudo tee -a /etc/php/*/mods-available/apcu.ini
sudo -u www-data php occ config:system:set memcache.local --value='\OC\Memcache\APCu'
sudo systemctl reload apache2
Log in at https://cloud.example.fr with the admin account, then open Administration settings, Overview: Nextcloud lists the settings still to fix there, for example a PHP memory limit that is too low (memory_limit in Apache's php.ini, to raise to 512M). Also enable two-factor authentication for the admin account.
04
Method 2: Nextcloud All-in-One with Docker
Nextcloud All-in-One (AIO) is the official Docker installation: a master container installs and updates all the others (Nextcloud, database, cache, HTTPS certificate, and optionally Talk or document editing). Pick one method or the other: AIO uses ports 80 and 443 itself and cannot share the same VPS with the previous installation.
Install Docker with the official script (see the guide install Docker on a VPS), then start the master container with the command from the AIO documentation:
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
Then open https://adresse-ip-du-vps:8080 (the certificate there is self-signed, which is expected), write down the passphrase shown, and enter your domain name: AIO checks that it points to the server, gets the certificate and starts the containers. To store files in a folder of the VPS rather than in a Docker volume, the NEXTCLOUD_DATADIR variable is set on the master container before the first installation.
Know this before choosing AIO on a container VPS: the AIO documentation recommends a KVM virtual machine or a physical server. In an LXC container, its backup container (BorgBackup) only starts if FUSE is enabled in the container. If it is not, make your own backups as described below, or prefer the package-based method.
05
Ports, firewall and storage
For a package-based install, only SSH, HTTP (for Let's Encrypt and the redirect) and HTTPS need to be open:
sudo apt install -y ufw
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable
With All-in-One, it is different: Docker publishes its containers' ports itself (80, 443, the AIO interface on 8080 and 8443, and 3478 over TCP and UDP if you enable Talk, Nextcloud's video calls) without going through ufw. A ufw rule is therefore not enough to close port 8080: keep the AIO passphrase to yourself. While Nextcloud is running, AIO also blocks direct login to its interface; you get back to it from the Nextcloud administration overview. The guide secure a Linux VPS covers ufw in detail.
A few rules for storage:
- Watch the disk with
df -h: a full disk blocks uploads and can break an update.
- Set a quota per user on the Accounts page of the administration, so a single person cannot fill everything.
- Tune the trash bin and versions: they take space. The
trashbin_retention_obligation and versions_retention_obligation options in config.php set how long they are kept.
- Do not add files directly to
/var/nextcloud-data: Nextcloud would not see them. If you do it anyway, sudo -u www-data php occ files:scan --all makes them appear.
06
Backups and updates
A Nextcloud backup has three parts: the config folder, the data folder and the database. The documentation recommends switching to maintenance mode during the copy, so the database and files stay consistent:
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
sudo mariadb-dump --single-transaction nextcloud > ~/nextcloud-db-$(date +%F).sql
sudo rsync -Aax /var/www/nextcloud/config /var/nextcloud-data ~/nextcloud-db-$(date +%F).sql utilisateur@autre-machine:/sauvegardes/nextcloud/
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off
The rsync command runs as root, because the data folder belongs to www-data: the destination machine must therefore accept root's SSH key. Always send the copy off the VPS: a backup on the same disk protects against neither a failure nor a mistake. A VPS snapshot complements this copy before an update, without replacing it. With All-in-One, enable the daily backup in its interface instead (if FUSE is available), which can also update the containers afterwards.
To update a package-based install:
sudo -u www-data php /var/www/nextcloud/updater/updater.phar
sudo -u www-data php /var/www/nextcloud/occ app:update --all
Nextcloud updates one major version at a time: you do not skip versions. Before moving to a new major version, check in the official requirements that your system's PHP version is still supported, and make a backup. With All-in-One, updates are done from the interface: Stop containers, then Start and update containers.
07
What CloudFive offers, and when it is not the right choice
To host Nextcloud, CloudFive offers two Linux VPS in France:
- the Ryzen VPS, on Ryzen 9 9950X with DDR5 memory and NVMe disk, for a fast interface and preview generation;
- the Intel VPS, on Xeon E5-2687W v4 with DDR4 ECC memory, our cheapest VPS, for a family cloud or a small team;
- both are Linux containers (LXC) with nesting enabled, where Docker works, with root access, a dedicated IPv4 address and editable reverse DNS, a 1 Gb/s port and basic DDoS protection included;
- snapshots are taken from the customer area, and changing plans does not require a reinstall when your files need more room.
The servers are in France, run by CLOUD FIVE, a French company, on its own network AS218808: your files stay stored in France. It is monthly, with no commitment, and support answers in French by ticket, on Discord and by phone, 7 days a week. Prices are on the pricing page.
It is not the right choice if:
- you do not want to administer anything: a Nextcloud needs regular updates and backups. CloudWork, CloudFive's office suite, already includes a Cloud hosted in France and managed by us; the standalone Cloud opens soon (see the Cloud page). The guide French cloud storage helps you compare;
- you want All-in-One's built-in backup and a full virtual machine, or you store several terabytes: a dedicated server gives you the room and control of the kernel;
- your users are far from France: every upload and every sync feels the distance.
To replace Google Drive step by step, see also the French alternative to Google Drive.
08
Frequently asked questions
How do I install Nextcloud on a VPS?
On an Ubuntu 24.04 or Debian 13 VPS, install Apache, PHP and MariaDB, create a database, download Nextcloud from download.nextcloud.com, run occ maintenance:install, then get an HTTPS certificate with Certbot. Another method: Docker with the official Nextcloud All-in-One image.
Nextcloud with Docker or a classic install, which should I choose?
All-in-One (Docker) installs and updates the database, cache and HTTPS on its own, but its built-in backup requires FUSE inside an LXC container. The package-based install takes more commands, but works everywhere and is backed up with rsync and mariadb-dump.
Which ports do I need to open for Nextcloud?
Ports 80 and 443 over TCP, plus SSH for administration. Nextcloud All-in-One also uses 8080 over TCP for its interface (8443 to reach it with a valid certificate), and 3478 over TCP and UDP if you enable Talk. Note: Docker publishes these ports without going through ufw.
How much RAM does Nextcloud need?
The Nextcloud documentation requires at least 128 MB per PHP process and recommends 512 MB per process. For family use or a small team, a small VPS is enough; disk space is what mostly decides the plan.
How do I back up Nextcloud?
Switch to maintenance mode with occ maintenance:mode --on, export the database with mariadb-dump, copy the config folder and the data folder with rsync to another machine, then turn maintenance mode off. With All-in-One, enable the daily BorgBackup backup in its interface.
Where can I host Nextcloud in France?
On a Linux VPS hosted in France by a French company. CloudFive offers Ryzen 9 9950X or Intel Xeon VPS in France, with root access, a dedicated IPv4 and basic DDoS protection included, monthly with no commitment; Docker works on them.