Skip to content

Nextcloud

Prefer one command? Try the Nextcloud Playbook

Nextcloud provides file storage, synchronization, sharing, calendars, and contacts on your own Asteroid.

Website
Nextcloud
License
AGPLv3
Last changed
2026-12-04

Tested with Nextcloud 35.0.3 on Uberspace 8.0.105. We can't guarantee it to work with newer versions.

Report a guide issue

Prerequisites

Note

Start with a fresh Asteroid and an empty document root. Do not use these installation commands to upgrade an existing Nextcloud.

This guide uses PHP, PostgreSQL, and Valkey. PostgreSQL 18 is among Nextcloud's recommended database versions.

PHP settings

Select PHP 8.4 and create its configuration directory. Example output:

[isabell@moondust ~]$ uberspace tool php version set 8.4
OK: Set version of php to 8.4
[isabell@moondust ~]$ mkdir -p ~/.config/php

Create ~/.config/php/nextcloud.ini:

memory_limit=512M
output_buffering=0
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.validate_timestamps=1
opcache.revalidate_freq=2
apc.enable_cli=1
apc.shm_size=64M

In the existing ~/.config/php-fpm.conf, change these two settings and keep the rest of the file:

pm.max_children = 2
pm.process_idle_timeout = 30s

The PHP memory limit applies per process. Two workers limit concurrent web requests; additional requests wait. Keep Uberspace's other PHP defaults, including disable_functions and open_basedir.

Validate the configuration and reload PHP-FPM. Example output is abbreviated:

[isabell@moondust ~]$ php-fpm --test --fpm-config ~/.config/php-fpm.conf
[...] NOTICE: configuration file /home/isabell/.config/php-fpm.conf test is successful
[isabell@moondust ~]$ uberspace web php reload
OK: PHP-FPM service reloaded

Installation

Download Nextcloud

Download the release into a temporary directory outside the document root. Verify its checksum before extracting it. The && prevents extraction when checksum verification fails. Example output omits download progress:

[isabell@moondust ~]$ NEXTCLOUD_DOWNLOAD=$(mktemp -d)
[isabell@moondust ~]$ cd "$NEXTCLOUD_DOWNLOAD"
[isabell@moondust tmp.example]$ curl --fail --location --remote-name https://download.nextcloud.com/server/releases/latest.tar.bz2
[isabell@moondust tmp.example]$ curl --fail --location --remote-name https://download.nextcloud.com/server/releases/latest.tar.bz2.sha256
[isabell@moondust tmp.example]$ sha256sum --check --ignore-missing latest.tar.bz2.sha256 && tar --extract --bzip2 --file=latest.tar.bz2 --directory="/var/www/virtual/$USER/html" --strip-components=1 --no-same-owner --same-permissions
latest.tar.bz2: OK
[isabell@moondust tmp.example]$ cd /var/www/virtual/$USER/html
[isabell@moondust html]$ rm --force nocontent.html
[isabell@moondust html]$ rm --recursive "$NEXTCLOUD_DOWNLOAD"

Continue only after checksum verification and extraction succeed. --same-permissions preserves the release's file permissions so the web server can read it even when your shell uses a restrictive umask.

Create the database

Create a dedicated database using Uberspace's PostgreSQL command. Example output:

[isabell@moondust html]$ uberspace tool postgresql database add "${USER}_nextcloud"
OK: Added PostgreSQL database 'isabell_nextcloud' to your Asteroid

Database creation takes a few seconds. Before continuing, check that it accepts connections. If it reports that the database does not exist yet, wait a few seconds and repeat. Example output:

[isabell@moondust html]$ psql --no-psqlrc --host=localhost --dbname="${USER}_nextcloud" --command='SELECT 1'
 ?column?
----------
        1
(1 row)

Do not reuse a database containing an earlier installation. Leave the platform's preinstalled PostgreSQL extensions in place.

Install Nextcloud

Have your PostgreSQL password from ~/.pgpass ready. Use the entry for your Asteroid username, not the read-only user ending in _ro.

Run the installer from the document root. It prompts for the database password and a new Nextcloud admin password; both inputs are hidden. Your admin username will be your Asteroid name. Example output:

[isabell@moondust html]$ php occ maintenance:install --database=pgsql --database-host=localhost --database-name="${USER}_nextcloud" --database-user="$USER" --admin-user="$USER" --data-dir="$HOME/nextcloud_data"
What is the password to access the database with user <isabell>?
What is the password you like to use for the admin account <isabell>?
Nextcloud was successfully installed

Configuration

Run the following occ commands from /var/www/virtual/$USER/html.

Domain and URLs

Use your default Asteroid domain, or replace it with a custom domain whose DNS is configured. Example output:

[isabell@moondust html]$ php occ config:system:set trusted_domains 0 --value="$USER.uber.space"
System config value trusted_domains => 0 set to string isabell.uber.space
[isabell@moondust html]$ php occ config:system:set overwrite.cli.url --value="https://$USER.uber.space"
System config value overwrite.cli.url set to string https://isabell.uber.space
[isabell@moondust html]$ php occ config:system:set htaccess.RewriteBase --value=/
System config value htaccess.RewriteBase set to string /
[isabell@moondust html]$ php occ maintenance:update:htaccess
.htaccess has been updated

Open your Nextcloud domain and log in. Under Administration settings > System, confirm that the web runtime reports a 512 MB PHP memory limit. This also checks that PHP-FPM loaded your configuration.

Configure email

Use local sendmail with your Uberspace address as the sender. No SMTP credentials are needed. Example output:

[isabell@moondust html]$ php occ config:system:set mail_smtpmode --value=sendmail
System config value mail_smtpmode set to string sendmail
[isabell@moondust html]$ php occ config:system:set mail_sendmailmode --value=pipe
System config value mail_sendmailmode set to string pipe
[isabell@moondust html]$ php occ config:system:set mail_from_address --value="$USER"
System config value mail_from_address set to ***REMOVED SENSITIVE VALUE***
[isabell@moondust html]$ php occ config:system:set mail_domain --value=uber.space
System config value mail_domain set to ***REMOVED SENSITIVE VALUE***

Nextcloud redacts the sender values in its output. This example sends from isabell@uber.space.

Set an address you can receive mail at under Personal settings > Personal info. Then use Send email under Administration settings > Basic settings > Email server, and check your inbox and spam folder.

Caching and file locks

First, set up the private Unix-socket service from the Valkey Manual. Verify it before enabling Nextcloud's shared cache. Example output:

[isabell@moondust html]$ valkey-cli -s ~/.valkey/valkey.sock PING
PONG
[isabell@moondust html]$ php occ config:system:set redis host --value="$HOME/.valkey/valkey.sock"
System config value redis => host set to ***REMOVED SENSITIVE VALUE***
[isabell@moondust html]$ php occ config:system:set redis port --type=integer --value=0
System config value redis => port set to integer 0
[isabell@moondust html]$ php occ config:system:set memcache.local --value='\OC\Memcache\APCu'
System config value memcache.local set to string \OC\Memcache\APCu
[isabell@moondust html]$ php occ config:system:set memcache.distributed --value='\OC\Memcache\Redis'
System config value memcache.distributed set to string \OC\Memcache\Redis
[isabell@moondust html]$ php occ config:system:set memcache.locking --value='\OC\Memcache\Redis'
System config value memcache.locking set to string \OC\Memcache\Redis

APCu handles the local cache; Valkey handles shared caching and file locks. Keep Valkey running during file operations. Upload, rename, and delete a test file, then check Administration settings > Overview for cache or file-locking warnings.

Background jobs

Create the directory for a lock file, enable cron mode, and choose a maintenance window. The example window starts at 01:00 UTC and lasts four hours. Example output:

[isabell@moondust html]$ mkdir -p ~/.cache
[isabell@moondust html]$ php occ background:cron
Set mode for background jobs to 'cron'
[isabell@moondust html]$ php occ config:system:set maintenance_window_start --type=integer --value=1
System config value maintenance_window_start set to integer 1

Add this line to your crontab:

*/5 * * * * /usr/bin/flock -n "$HOME/.cache/nextcloud-cron.lock" /usr/bin/php -f "/var/www/virtual/$USER/html/cron.php" > "$HOME/logs/nextcloud-cron.log" 2>&1

The lock prevents overlapping runs. After the first run, check the last background-job execution under Administration settings > Basic settings. If it has not run, inspect ~/logs/nextcloud-cron.log.

Client Push

Client Push reduces polling by compatible clients. Complete the Valkey configuration first, then install the app. Example output:

[isabell@moondust html]$ php occ app:install notify_push
notify_push 1.4.2 installed
notify_push enabled
[isabell@moondust html]$ mkdir -p ~/.config/nextcloud-push

Client Push needs a local callback route because Uberspace's public frontend removes the forwarded address used by its proxy check. Create ~/.config/nextcloud-push/Caddyfile:

{
    admin off
    auto_https off
}
http://127.0.0.1:7868 {
    bind 127.0.0.1
    root * /var/www/virtual/{$USER}/html
    handle /index.php/apps/notify_push/* {
        php_fastcgi unix//var/lib/php-fpm/{$USER}/php-fpm.sock {
            header_up X-Forwarded-For {http.request.header.X-Forwarded-For}
        }
    }
    handle {
        respond 404
    }
}

Keep this callback private: do not add a public backend for port 7868.

Create ~/.config/systemd/user/nextcloud-push-callback.service:

[Unit]
After=php-fpm.service

[Service]
ExecStart=/usr/bin/caddy run --config %h/.config/nextcloud-push/Caddyfile
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target

Create ~/.config/systemd/user/notify_push.service:

[Unit]
After=valkey.service nextcloud-push-callback.service
Requires=nextcloud-push-callback.service

[Service]
Type=notify
Environment=PORT=7867
Environment=NEXTCLOUD_URL=http://127.0.0.1:7868
ExecStart=/var/www/virtual/%u/html/apps/notify_push/bin/x86_64/notify_push /var/www/virtual/%u/html/config/config.php
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target

Systemd substitutes %h with your home directory and %u with your username. Allow and trust the loopback callback, then start both services. These indices assume this guide's fresh installation. Example output is abbreviated:

[isabell@moondust html]$ php occ config:system:set trusted_domains 1 --value=127.0.0.1:7868
System config value trusted_domains => 1 set to string 127.0.0.1:7868
[isabell@moondust html]$ php occ config:system:set trusted_proxies 0 --value=127.0.0.1
System config value trusted_proxies => 0 set to string 127.0.0.1
[isabell@moondust html]$ systemctl --user daemon-reload
[isabell@moondust html]$ systemctl --user enable --now nextcloud-push-callback notify_push
Created symlink '...' → '.../nextcloud-push-callback.service'.
Created symlink '...' → '.../notify_push.service'.

Route your domain's root to Apache and /push to Client Push. Replace the domain if you use a custom one. These commands set the routes for this Nextcloud installation, replacing existing entries at those paths. Example output:

[isabell@moondust html]$ uberspace web backend add "$USER.uber.space/" apache --force
OK: Added webbackend 'isabell.uber.space/' to your Asteroid
[isabell@moondust html]$ uberspace web backend add "$USER.uber.space/push" port 7867 --remove-prefix --force
OK: Added webbackend 'isabell.uber.space/push' to your Asteroid

Wait for the routes to take effect, then verify the setup. All six checks must pass. Example output:

[isabell@moondust html]$ php occ notify_push:setup "https://$USER.uber.space/push"
✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
✓ push server is running the same version as the app
  configuration saved

A temporary 404 can mean the new route has not propagated yet; wait and retry. For other failures, check the service logs for notify_push and nextcloud-push-callback. Keep the trusted proxy limited to loopback.

Nextcloud Talk (optional)

Install Talk for chat, calls, and screen sharing. Example output:

[isabell@moondust html]$ php occ app:install spreed
spreed 25.0.8 installed
spreed enabled

Open Talk, create a conversation, and test messages and calls between two users on different networks. Allow microphone and camera access in both browsers.

Some networks need a separate TURN service. Configure it under Administration settings > Talk and run the connection test there. This guide installs neither TURN nor Talk's optional high-performance backend.

Setup checks

After installing your apps, add optional database indices, run the mimetype migrations, and set the default region for phone numbers without a country code. Both maintenance commands are quick on a fresh installation. Example output is abbreviated:

[isabell@moondust html]$ php occ db:add-missing-indices --no-interaction
[...]
[isabell@moondust html]$ php occ maintenance:repair --include-expensive --no-interaction
[...]
[isabell@moondust html]$ php occ config:system:set default_phone_region --value=DE
System config value default_phone_region set to string DE

Enable HSTS for your domain so browsers always use HTTPS. Example output:

[isabell@moondust html]$ uberspace web header add "$USER.uber.space/" Strict-Transport-Security max-age=15552000
OK: Added webheader 'isabell.uber.space/' to your Asteroid

Then open Administration settings > Overview. Without Talk's high-performance backend, Talk reports an error that only matters for calls with more than two or three participants. A PostgreSQL cache-hit warning depends on the shared database server and can appear on a new installation.

Updates

Note

Check the Nextcloud changelog regularly. Back up your application files, config/, data directory, and database before updating. For PostgreSQL exports, use the Manual's dump instructions, including its PostGIS exclusions.

Schedule daily core and app updates using Nextcloud's non-interactive updater. The updater backs up application code, but does not back up your database or data directory. Keep those backups separately.

Create ~/bin if it does not exist, then save this script as ~/bin/nextcloud-update:

#!/bin/bash
set -euo pipefail
export PATH=/usr/local/bin:/usr/bin:/bin
cd "/var/www/virtual/$USER/html"
php occ status --exit-code
case "${1:-}" in
  core) php updater/updater.phar --no-interaction ;;
  apps) php occ app:update --all --no-interaction ;;
  *) echo "Usage: $0 core|apps" >&2; exit 2 ;;
esac
php occ upgrade --no-interaction
systemctl --user restart notify_push
url=$(php occ config:system:get overwrite.cli.url)
php occ notify_push:setup "${url%/}/push"

Make it executable and test both update paths. Example output for an up-to-date installation is abbreviated:

[isabell@moondust ~]$ chmod 700 ~/bin/nextcloud-update
[isabell@moondust ~]$ flock -w 3600 "$HOME/.cache/nextcloud-cron.lock" "$HOME/bin/nextcloud-update" core
[...]
No update available.
[...]
  configuration saved
[isabell@moondust ~]$ flock -w 3600 "$HOME/.cache/nextcloud-cron.lock" "$HOME/bin/nextcloud-update" apps
[...]
All apps are up-to-date or no updates could be found
[...]
  configuration saved

Add these two jobs to your crontab. They run daily at 03:15 and 04:15 in the server's timezone:

15 3 * * * /usr/bin/flock -w 3600 "$HOME/.cache/nextcloud-cron.lock" "$HOME/bin/nextcloud-update" core > "$HOME/logs/nextcloud-update-core.log" 2>&1
15 4 * * * /usr/bin/flock -w 3600 "$HOME/.cache/nextcloud-cron.lock" "$HOME/bin/nextcloud-update" apps > "$HOME/logs/nextcloud-update-apps.log" 2>&1

Updates and background jobs share the same lock. Updates wait up to one hour for it; background jobs skip a run while an update holds it. Each update stops on failure, and subsequent runs refuse to proceed if maintenance mode or a pending database upgrade requires attention. Do not force maintenance mode off after a failed update: inspect the update log and finish or repair the failed step first.

Both jobs restart Client Push and check its public route after successful updates. Check ~/logs/nextcloud-update-core.log and ~/logs/nextcloud-update-apps.log after the first scheduled runs and regularly afterward. Each log contains the latest run. Also check Administration settings > Overview and verify file upload and download. Application errors are recorded in ~/nextcloud_data/nextcloud.log.