Install Nextcloud 15 on Ubuntu 18.04 with ISPConfig 3.1

How to install Nextcloud 15 with HSTS, PHP OPCache, APCu, Redis and Pretty URLs.

Furthermore, in this tutorial is explained how to install the apps

  • Preview Generator
  • Collabora Online.

PHP  7.0, 7.1 or 7.2 is required for Nextcloud 15. In this manual we choose PHP 7.2 according to our existing ISPConfig installation. Note that PHP 7.0 is end of life at 10 Jan 2019. EOL of PHP 7.2 is about end of year 2020.

Check installed PHP modules

php -m

Check loaded php.ini

sudo -u web1 php -i | grep php\.ini

Install packages

apt update && apt upgrade
apt -y install apache2 mariadb-server php-imagick php-smbclient redis-server php-redis php-apcu
apt -y install libapache2-mod-php7.2 php7.2-gd php7.2-json php7.2-mysql php7.2-curl php7.2-mbstring php7.2-intl php7.2-xml php7.2-zip php7.2-gmp
apt -y install ffmpeg libreoffice libreoffice-l10n-de libreoffice-help-de

Install Nextcloud

Create two virtual hosts including Lets Encrypt SSL and Fast-CGI with ISPConfig, one for your Nextcloud instance (e.g. nextcloud.domain.xx) and one for the Collabora Online app, e.g. collabora.domain.xx.

With ISPConfig, create a MySQL user and database.

Download Nextcloud:

Go to the webroot of your Nextcloud domain, delete everything within it, unzip the downloaded file and change to the correct ownership.

chown -R web1:client1 nextcloud

Move all files in the nextcloud folder to the parent directory and remove the empty folder after.

rmdir nextcloud

Open your Nextcloud domain in the browser and follow the installation instructions.

If you want to change the Nextcloud data path, add it to ISPConfig | Sites | Nextcloud-domain | Options | PHP open_basedir before running the Nextcloud web installer.

Done! Nextcloud 15 is now installed and ready to use.

Configure Nextcloud

As Nextcloud Admin, go to Settings | Overview and check the Security and setup warnings.


Enable mod_headers to activate HSTS:

a2enmod headers && service apache2 restart

Add the following line to ISPConfig | Sites | Nextcloud-domain | Options | Apache Directives

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

PHP OPcache

You should use the following settings in the php.ini at the [opcache] section


To achive it, add it to ISPConfig | Sites | Nextcloud-domain | Options | Custom php.ini settings


Add to config.php

'memcache.local' => '\OC\Memcache\APCu',


Add to config.php

'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' =>
  array (
  'host' => 'localhost',
  'port' => 6379,

occ db:convert-filecache-bigint

Set your Nextcloud instance into maintenace mode by adding

'maintenance' => true,

to config.php

then go to the webroot of your Nextcloud domain and execute

sudo -u web1 php occ db:convert-filecache-bigint

Disable maintenance mode.


All checks passed.


crontab -e -u web1
*/15 * * * * php -f /var/www/nextcloud.domain.xx/web/cron.php

Enable the cronjob in Nextcloud with Basic settings | Background jobs | Cron


Add to PHP open_basedir with ISPConfig at your Nextcloud domain:


Pretty URLs

How to remove index.php of your URLs.

Add the following line to config.php

'htaccess.RewriteBase' => '/',


occ maintenance:update:htaccess


Create a filter and jail for Nextcloud.


Nextcloud 15 is now fully configured – it’s time to install apps.

Before upgrading to Nextcloud 16 it’s recommended to upgrade the MySQL datasbase to 4-byte support.

Install Apps