Nextcloud is an open source cloud solution written in PHP and distributed under the AGPLv3 license.

Nextcloud was initially released in 2016 as a fork of ownCloud and is maintained by Nextcloud GmbH.


For this guide you should be familiar with the basic concepts of


We’re using PHP in the stable version 7.4:

[isabell@stardust ~]$ uberspace tools version show php
Using 'PHP' version: '7.4'
[isabell@stardust ~]$

You’ll need your MySQL credentials. Get them with my_print_defaults:

[isabell@stardust ~]$ my_print_defaults client
[isabell@stardust ~]$

If you want to use your cloud with your own domain you need to setup your domain first:

[isabell@stardust ~]$ uberspace web domain list
[isabell@stardust ~]$


PHP settings

Before you start the actual app installation you should have set the proper php settings. Otherwise Nextcloud would warn you after each command execution because of the wrong set memory limit.


Enable opcache to optimise performance.

To do that, create ~/etc/php.d/opcache.ini with the content:


PHP Memory

In order to increase the memory limit of php to the recommended minimum value of 512 MB, create ~/etc/php.d/memory_limit.ini with the following content:


Output Buffering

Disable output buffering, create ~/etc/php.d/output_buffering.ini with the following content:


PHP Reload

After that you need to restart PHP configuration to load the changes:

[isabell@stardust ~]$ uberspace tools restart php
Your php configuration has been loaded.
[isabell@stardust ~]$


cd to your document root, then download the latest release of the Nextcloud and extract it:


The link to the latest version can be found at Nextcloud’s download page.

[isabell@stardust ~]$ cd html
[isabell@stardust html]$ curl | tar -xjf - --strip-components=1
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
 100 37.5M  100 37.5M    0     0  5274k      0  0:00:07  0:00:07 --:--:-- 6062k
[isabell@stardust html]$



We strongly recommend you to use the MySQL backend for nextcloud. Do not use the SQLite backend for production. It gives you a better performance and reduces disk load on the host you share.

You need to change the following tree highlighted parameters to prepare the install command below:

  • Administrator username and password: Insert the credentials you want to use for the admin user

  • Get your MySQL Password

[isabell@stardust html]$ mysql --verbose --execute="CREATE DATABASE ${USER}_nextcloud"
CREATE DATABASE isabell_nextcloud

[isabell@stardust html]$ ADMIN_USER=MyUserName
[isabell@stardust html]$ ADMIN_PASS=MySuperSecretAdminPassword
[isabell@stardust html]$ MYSQL_PASSWORD=MySuperSecretMySQLPassword
[isabell@stardust html]$ php occ maintenance:install --admin-user "${ADMIN_USER}" --admin-pass "${ADMIN_PASS}" --database 'mysql' --database-name "${USER}_nextcloud"  --database-user "${USER}" --database-pass "${MYSQL_PASSWORD}" --data-dir "${HOME}/nextcloud_data"
Nextcloud was successfully installed
[isabell@stardust html]$

You should now set your domain.

[isabell@stardust html]$ php occ config:system:set trusted_domains 0 --value=""
System config value trusted_domains => 0 set to string
[isabell@stardust html]$ php occ config:system:set overwrite.cli.url --value=""
System config value overwrite.cli.url set to string
[isabell@stardust html]$

Set links to the log file destinations so you can easily access them in case you need them.

[isabell@stardust html]$ ln --symbolic ~/nextcloud_data/nextcloud.log ~/logs/nextcloud.log
[isabell@stardust html]$ ln --symbolic ~/nextcloud_data/updater.log ~/logs/nextcloud-updater.log
[isabell@stardust html]$

You can already access your Nextcloud, but it is highly recommended to continue with a proper configuration and also some tuning to enhance the performance.


Currently your Nextcloud installation is not capable of sending mail, e.g. for notifications or password resets. You can do this by executing the commands in the following block or by editing the ~/html/config/config.php with your favorite editor. If you want to keep things simple, use sendmail. Alternatively log in with your admin user, go to settings > Administration > Basic settings and configure the email-server.

Sendmail Settings

For the basic system mail configuration just run the following commands.
You can also change the mail_from_adress or the mail_domain if you have set up additional mail domains
[isabell@stardust html]$ php occ config:system:set mail_domain --value=""
System config value mail_domain set to string
[isabell@stardust html]$ php occ config:system:set mail_from_address --value="$USER"
System config value mail_from_address set to string isabell
[isabell@stardust html]$ php occ config:system:set mail_smtpmode --value="sendmail"
System config value mail_smtpmode set to string sendmail
[isabell@stardust html]$ php occ config:system:set mail_sendmailmode --value="pipe"
System config value mail_sendmailmode set to string pipe


If you prefer an advanced configuration read the Nextcloud admin manual for email.
You can also set all settings via the web based admin interface.


URL rewriting

If you prefer prettier URLs without index.php run the following two commands.

[isabell@stardust html]$ php occ config:system:set htaccess.RewriteBase --value='/'
System config value htaccess.RewriteBase set to string /
[isabell@stardust html]$ php occ maintenance:update:htaccess
.htaccess has been updated
[isabell@stardust html]$


For better performance, Nextcloud suggests to add a local cronjob.

Add the following cronjob to your crontab:

*/5  *  *  *  * php -f $HOME/html/cron.php > $HOME/logs/nextcloud-cron.log 2>&1


To further enhance performance, enable Memcaching.

APCu caching

To enable Memcaching (APCu), execute the following commands:

[isabell@stardust html]$ php occ config:system:set memcache.local --value='\OC\Memcache\APCu'
System config value memcache.local set to string \OC\Memcache\APCu
[isabell@stardust html]$

Redis caching

To reduce load on the mysql server and also improve transactional file locking you may follow the redis guide on the lab and then execute the following commands:

[isabell@stardust html]$ php occ config:system:set redis host --value="${HOME}/.redis/sock"
System config value redis => host set to string /home/isabell/.redis/sock
[isabell@stardust html]$ php occ config:system:set redis port --value=0
System config value redis => port set to string 0
[isabell@stardust html]$ php occ config:system:set redis timeout --value=1.5
System config value redis => timeout set to string 1.5
[isabell@stardust html]$ php occ config:system:set filelocking.enabled --value='true'
System config value filelocking.enabled set to string true
[isabell@stardust html]$ php occ config:system:set memcache.locking --value='\OC\Memcache\Redis'
System config value memcache.locking set to string \OC\Memcache\Redis
[isabell@stardust html]$ php occ config:system:set memcache.distributed --value='\OC\Memcache\Redis'
System config value memcache.distributed set to string \OC\Memcache\Redis

In the Nextcloud admin manual you can find more Information about memory caching and transactional file locking.

Database maintenance

To adapt some database configs to make Nextcloud run smoother execute these commands:

[isabell@stardust ~]$ cd html
[isabell@stardust html]$ php occ db:add-missing-indices --no-interaction
[isabell@stardust html]$ php occ db:convert-filecache-bigint --no-interaction


Onlyoffice (Community Edition)

To edit text and spreadsheet documents, you need to install and enable these apps from the admin interface:

  • Community Document Server (a light version of the Onlyoffice server)

  • Onlyoffice (the connector to the Onlyoffice server)

Both apps can be installed optional during the main install, but the huge document server may fail. Then install it manually from the shell:

[isabell@stardust html]$ cd apps
[isabell@stardust apps]$ curl -L | tar -xvzf -

Reload the admin panel and enable the Community Document Server. A click on a text/spreadsheet document should now start the Onlyoffice Editor.

Nextcloud Talk

To enable video/audio calls in your instance, install and enable the “Talk” app in the admin interface. If the web installation fails, install the app manually in your shell:

[isabell@stardust html]$ cd apps
[isabell@stardust apps]$ curl -L | tar -xvzf -

Reload the page and press the talk icon in the top menu bar.


The easiest way to update Nextcloud is to use the web updater provided in the admin section of the Web Interface.

Updating via console command is also a comfortable way to perform upgrades. While new major releases of Nextcloud also introduce new features the updater might ask you to run some commands e.g. for database optimisation. The release cycle of Nextcloud is very short. A prepared script with some common checks would ensure you don’t need to run them.


Before updating to the next major release, such as version 19.x.x to 20.x.x, make sure your apps are compatible or there exists updates. Otherwise the incompatible apps will get disabled. If the web based admin overview displays an available update it also checks if there are any incompatible apps. You can also check for compatible versions in the Nextcloud App Store.

Create ~/bin/nextcloud-update with the following content:

#!/usr/bin/env bash
## Updater automatically works in maintenance:mode.
## Use the Uberspace backup system for files and database if you need to roll back.
## The Nextcloud updater creates backups only to safe base and app code data and config files
## so it takes ressources you might need for your productive data.
## Deactivate NC-updater Backups with --no-backup (works from 19.0.4, 18.0.10 and 17.0.10)
php ~/html/updater/updater.phar -vv --no-backup --no-interaction

## re-enable maintenance mode for occ commands
php ~/html/occ maintenance:mode --on

## database optimisations
## The following command works from Nextcloud 20.
## remove '#' so it is working
#php ~/html/occ db:add-missing-primary-keys --no-interaction
php ~/html/occ db:add-missing-columns --no-interaction
php ~/html/occ db:add-missing-indices --no-interaction
php ~/html/occ db:convert-filecache-bigint --no-interaction

php ~/html/occ app:update --all
php ~/html/occ maintenance:mode --off
/usr/sbin/restorecon -R ~/html

Make the script executable:

[isabell@stardust ~]$ chmod +x ~/bin/nextcloud-update
[isabell@stardust ~]$

Then you can run the script whenever you need it to perform the update.

[isabell@stardust ~]$ nextcloud-update
[isabell@stardust ~]$


You can automate this script as a cronjob.

@daily $HOME/bin/nextcloud-update output as email @daily $HOME/bin/nextcloud-update > $HOME/logs/nextcloud-update.log 2>&1 latest output as logfile


Check the changelog regularly or subscribe to the project’s Github release feed with your favorite feed reader to stay informed about new updates and releases.


403 errors

If you have installed Nextcloud on a subdomain it can happen that the update fails: Access to the UI is not possible and HTTP 403 errors are thrown. In most cases this happens due to wrong SELinux labels which can be fixed with finishing the update via console and setting the labels according the loaded SELinux policy.

[isabell@stardust ~]$ cd html
[isabell@stardust html]$ php occ upgrade
[isabell@stardust html]$ restorecon -R .
[isabell@stardust html]$ php occ maintenance:mode --off
[isabell@stardust html]$

missing files

If files are missing like if you move files or restore backups on the machine and not via web you can perform a scan.

[isabell@stardust ~]$ cd html
[isabell@stardust html]$ php occ files:scan --all
[isabell@stardust html]$ php occ files:scan-app-data
[isabell@stardust html]$

storage capacity problems

If you use large apps like onlyoffice, your backups can get very large in relation to your storage capacity. Nextcloud always keeps the last 3 backups and deletes the older ones.
Depending on your storage quota you may run into issues so you may want to delete some backups. The Updater will store the backups in a folder with a generated suffix updater-XXXXX inside the data directory.
e.g. according to the recommended data location:
if you did’t change the default setting:

Here is an example you probably don’t want to keep on your Uberspace. To get rid of the old version navigate to that path and run: rm --recursive nextcloud-19.*

ncdu 1.15.1 ~ Use the arrow keys to navigate, press ? for help
--- /home/isabell/nextcloud-data/updater-ocRANDOMg5/backups ----
  1,8 GiB [##########] /nextcloud-
  1,6 GiB [########  ] /nextcloud-
  1,6 GiB [########  ] /nextcloud-

Total disk usage:   4,9 GiB  Apparent size:   4,7 GiB  Items: 132481

Tested with Nextcloud 20.0.4, Uberspace

Written by: Andreas Matschl | SpaceCode <>, EV21 <>