Nextcloud on Synology

Nextcloud is a suite of client-server software for creating and using file hosting services. It is functionally similar to Dropbox, although Nextcloud is free and open-source, allowing anyone to install and operate it on a private server.

This document describes, how to install Nextcloud on a Synology DiskStation.

Prerequisites

Hostname in DNS

Dynamic or static address mapping.

Mail Account

For Nextcloud to send out mail notifications.

Firewall

NAT and or access rules to allow/forward HTTPS traffic to the Synology NAS.

Packages

Currently (January 2019) there is no Nextcloud package available, neither from Synology nor from any third parties.

To install Nextcloud manually the following packages from Synology need to be installed first:

  1. WebStation;
  2. Apache HTTP Server 2.4
  3. PHP 7.2;
  4. MariaDB (10.3.7) database server;

WebStation

In the DSM open WebStation.

WebStation PHP Settings

Select “PHP Settings” and click the “Create” button.

Common Settings:

Profile Name: Nextcloud

Description:

PHP Version: PHP 7.2

Enable PHP cache: Yes

Customize PHP open_basedir: Yes

open_basedir:

  • /tmp
  • /var/services/tmp
  • /var/services/web
  • /var/services/homes
  • /volume1/nextcloud
  • /dev/urandom
  • /proc/meminfo

PHP Modules required (see also the Admin Manual for a list of required and recommended modules by Nextcloud)

  • bz2
  • curl
  • exif
  • gd
  • gmp
  • iconv
  • intl
  • mcrypt
  • openssl
  • pdo_mysql
  • posix
  • zip

Recommended but not available:

  • imagick

FPM:

No changes.

Core:

php.ini settings as recommended by Nextcloud php.ini configuration notes

Name Value
max_input_time 120
opcache.enable 1
opcache.enable_cli 1
opcache.interned_strings_buffer 8
opcache.max_accelerated_files 10000
opcache.memory_consumption 128
opcache.save_comments 1
opcache.revalidate_freq 1
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 zend_extension = opcache.so
 extension = apcu.so

 extension = bz2.so
 extension = curl.so
 extension = exif.so
 extension = gd.so
 extension = gmp.so
 extension = iconv.so
 extension = intl.so
 extension = mcrypt.so
 extension = openssl.so
 extension = pdo_mysql.so
 extension = posix.so
 extension = zip.so

 display_errors = Off
 open_basedir = /tmp:/var/services/tmp:/var/services/web:/var/services/homes:/volume1/nextcloud/:/dev/urandom:/proc/meminfo
 max_input_time = 120
 opcache.enable_cli = 1
 opcache.interned_strings_buffer = 8
 opcache.max_accelerated_files = 10000
 opcache.memory_consumption = 128
 opcache.revalidate_freq = 1

 [PATH=/volume1/web/nextcloud]
 open_basedir = /volume1/web/nextcloud:/tmp:/var/services/tmp:/var/services/web:/var/services/homes:/volume1/nextcloud/:/dev/urandom:/proc/meminfo

WebStation VirtualHost

Select “Virtual Host” and click the “Create” button.

Name based: Yes

Hostname: “cloud.example.net”

Port: 80/443

Document-Root: “web/nextcloud”

HTTPS Settings:

HSTS: Yes

HTTP/2: Yes

HTTP-Backend-Server: Apache HTTP Server 2.4

PHP: Nextcloud

PHP Command-Line Interface

Nextcloud needs command-line access for PHP for tasks like cronjobs, system and database upgrades and maintenance scripts.

The command-line environment should match the web-servers PHP script environment.

We therefore copy the web-servers PHP-FPM standard environment to a local user directory:

$ cp /usr/syno/etc/packages/WebStation/php70/php.ini /volume1/homes/admin/bin/occ.d/

The customized PHP environment is saved under a unique ID directory in /usr/syno/etc/packages/WebStation/php_profile.

Merge the entries of conf.d/user_settings.ini and conf.d/webstation_vhost.ini into your copy of /volume1/homes/admin/bin/occ.d/php.ini.

Be careful that there are no duplicate entries.