Self-Hosted Cloud Storage: Running Nextcloud on Your VPS

Published on | Updated

Set up Nextcloud on a VPS for private cloud storage: Ubuntu 24.04, MariaDB, PHP 8.3, Redis, Certbot HTTPS and sync apps, compared with Google Drive and Dropbox.

Illustration of three stacked server units with blue status lights next to a terminal window with green code

You want Dropbox-style file sync, plus your calendar and contacts, on a server you control instead of a provider's. Nextcloud does that: it is open source (AGPL-3.0), runs on a Linux VPS, and has sync apps for desktop and phone. This guide installs it with Apache, MariaDB, PHP and Redis on Ubuntu 24.04 LTS, following the example installation in the Nextcloud manual.

Nextcloud vs Commercial Cloud

Google gives every account up to 15 GB, shared across Gmail, Google Drive and Google Photos, and sells more storage through Google One plans that start at 100 GB. Dropbox Basic is free with 2 GB, and Dropbox Plus gives one person 2 TB. We checked both on their own pages on 31 October 2026 (Google storage help, Google One plans, Dropbox plans); see those pages for current prices.

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

What you get on the Nextcloud side:

  • Calendar, contacts, notes, chat and video calls through apps from the Nextcloud app store (see the table at the end).
  • Document editing through one of the office integrations the manual lists: Nextcloud Office or Collabora Online.
  • End-to-end encryption for the folders you choose. The End-to-End Encryption app encrypts files on your device before they reach the server. Server-side encryption is something else: the manual says it is mainly for files on external storage and does not protect data from a compromised Nextcloud server or a malicious administrator.

Installation

These steps follow the manual's example for Ubuntu 24.04 LTS, which is also the recommended image in the operating system step of Space-Node's VPS order form. Ubuntu 24.04 ships PHP 8.3 and MariaDB 10.11, both on the supported lists of Nextcloud 35, the current major version (35.0.2, released 15 October 2026). PHP 8.3 is the oldest PHP version Nextcloud 35 supports.

Prerequisites

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

Up to php-zip this is the manual's package list. php-apcu, php-redis and redis-server are for the caching step below, and bzip2 unpacks the download.

Database Setup

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, and the manual's database page sets it in the MariaDB server configuration, /etc/mysql/my.cnf. Add these lines there:

[mysqld]
transaction_isolation = READ-COMMITTED
binlog_format = ROW

Then restart MariaDB:

sudo systemctl restart mariadb

Download and Install

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

The checksum command must print latest.tar.bz2: OK. The --ignore-missing flag is there because the checksum file also lists a metadata file that you did not download; without the flag, sha256sum reports that file as unreadable and exits with an error.

Apache Configuration

Start with the manual's virtual host for plain HTTP on port 80. Certbot adds the HTTPS part in the next step, once the certificate exists. Create /etc/apache2/sites-available/nextcloud.conf:

<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 restart Apache:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
sudo systemctl restart apache2

SSL with Let's Encrypt

Point your domain's DNS record at the VPS first. Let's Encrypt checks a file on your domain over port 80 (its HTTP-01 challenge only works on that port), so port 80 must be reachable.

sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d cloud.yourdomain.com

Certbot's Apache plugin obtains the certificate and installs it in Apache. Check that renewal works with sudo certbot renew --dry-run.

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, and a custom folder must already exist and be owned by www-data. Read our Nextcloud storage planning guide before you choose.

Performance Optimization

Redis Caching

Add these lines inside the $CONFIG array. This is the manual's setup for a single server: APCu for the local cache, Redis for the distributed cache and for file locking.

// /var/www/nextcloud/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. systemctl status redis-server shows whether it runs, and sudo systemctl enable --now redis-server starts it and keeps it on after a reboot.

PHP Optimization

Apache's PHP reads its own php.ini: on Ubuntu 24.04 that is /etc/php/8.3/apache2/php.ini. Command-line PHP, which cron uses, reads /etc/php/8.3/cli/php.ini.

; /etc/php/8.3/apache2/php.ini
memory_limit = 512M
upload_max_filesize = 16G
post_max_size = 16G
max_input_time = 3600
max_execution_time = 3600
apc.shm_size = 128M

Restart Apache afterwards with sudo systemctl restart apache2. The manual says memory_limit should be at least 512 MB. The upload and time values are the examples from its page on big files, and the desktop sync client is not affected by these limits because it uploads in smaller chunks. apc.shm_size raises the APCu memory from its 32M default, which the manual calls usually too low for Nextcloud.

You do not need OPcache lines here: opcache.enable = 1 and opcache.memory_consumption = 128 are PHP's defaults already, and on Ubuntu 24.04 the OPcache module is installed as a dependency of Apache's PHP module. The manual's server tuning page lists the OPcache settings worth changing.

Background Jobs

By default Nextcloud runs background jobs with AJAX, one job each time a user loads a page. The manual recommends cron instead, every 5 minutes as the web server user:

sudo crontab -u www-data -e
*/5  *  *  *  * php -f /var/www/nextcloud/cron.php

Once cron has run cron.php, Nextcloud switches the background jobs setting to Cron by itself.

Sync Clients

PlatformAppAutomatic sync
WindowsNextcloud desktop clientKeeps your folders in sync
macOSNextcloud desktop clientKeeps your folders in sync
LinuxNextcloud desktop client (AppImage)Keeps your folders in sync
iOSNextcloud FilesAutomatic upload of photos and videos
AndroidNextcloud FilesAutomatic upload of photos and videos

Turn on automatic upload in the mobile app and new photos and videos go straight to your own server.

Storage Requirements

How much disk you need depends on more than your files. The Nextcloud manual says deleted files in the trash bin and older file versions are managed outside the normal user quota, and that thumbnails, temporary files and caches use disk space without counting against it. Our Nextcloud storage planning guide shows how to measure what you use, cap versions and the trash, size the disk, and move the data directory later.

Space-Node VPS plans use NVMe SSD storage in an EU data center, and the order form offers extra NVMe storage as an add-on if your files outgrow the plan's disk. Backups are not included in the plan price, so run your own or ask support about the backup option through a ticket.

Useful Nextcloud Apps

AppPurpose
CalendarCalendar that syncs events with your devices
ContactsContacts over CardDAV, synced with your devices
NotesNotes with Markdown formatting, saved as files
TalkChat plus video and audio calls
Nextcloud Office (Collabora)Document editing through a Collabora Online server
DeckKanban boards
BookmarksBookmarks synced across your browsers and devices
End-to-End EncryptionEncrypts the folders you choose on your device before upload

With these apps one Nextcloud server covers files, calendar, contacts, notes and video calls on your own VPS. Check an app's page in the app store for the Nextcloud versions it supports before you install it; on 31 October 2026 each app above listed Nextcloud 35.

Sources

All opened on 31 October 2026: