How to install Nextcloud on Synology

 

Prequisites

  • Web Station
  • Apache HTTP Server 2.4
  • PHP 7.3
  • phpMyAdmin 4.9.0 (at the time of writing this depends on php 5.6)
  • MariaDB 10

Configure MariaDB root password

  • In the Synology packet manager open MariaDB
  • Click on reset root password and set a password other than blank

Configure Web Station 

  • In the Synology packet manager open Web Station
  • In the left menu select General Settings
    • Set HTTP back-end server to Apache HTTP Server 2.4
    • Try to set PHP to PHP 7.3. If you are limited to 5.6 check the next section.

Optional: If Web Station does not allow to set PHP 7.3

  • In Web Station select PHP Settings in the left menu
  • Click on Create to create a new profile
    • Under General Settings tab:
      • Assign name (e.g. PHP 7.3 profile)
      • Assign description (e.g. using PHP 7.3)
      • Enable checkboxes for:
        • Enable PHP cache
        • Enable display_errors to display PHP error message
        • Customize PHP open_basedir
          • Enter: /dev/urandom:/var/services/tmp:/volume1/web:/volume1/web/nextcloud:/volume1/YOUR_NEXTCLOUD_DATA_FOLDER
      • Select and enable all extensions
    • Select Core tab
      • mysql.default_port=3307 (this is the default port for MariaDB 10)
      • memory_limit=512M
      • 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

Install Nextcloud 

chown -R http:http /volume1/web/nextcloud
  • Change file permissions: 
find /volume1/web/nextcloud/ -type f -print0 | xargs -0 chmod 777
  • Change directory permissions: 
find /volume1/web/nextcloud/ -type d -print0 | xargs -0 chmod 777
  • Create your data folder and assign permissions:
mkdir /volume1/YOUR_NEXTCLOUD_DATA_FOLDER
chown http:http /volume1/YOUR_NEXTCLOUD_DATA_FOLDER
chmod 777 /volume1/YOUR_NEXTCLOUD_DATA_FOLDER
  • Open Synology File Station and check properties of your data folder. Owner and permissions should be set correctly to http 
  • If your data folder is inside a shared folder, open Synology Shared Folder app and edit your shared folder
    • Under Permissions tab select Local Groups and make sure http has read/write access

Configure Nextcloud

  • Using your favorite browser open http://YOUR_DISKSTATION/nextcloud
  • In the welcome screen pick choose your administrator username/password
  • Click on "Storage & Database"
    • Under Data folder point to your data folder, e.g. /volume1/YOUR_NEXTCLOUD_DATA_FOLDER
    • Select MySQL/MariaDB as database
      • Use root as username and the password you set earlier in section "Configure MariaDB root password"
      • Database name can be anything, e.g. nextcloud
      • Change "localhost" to "127.0.0.1:3307"
    • Click on Finish Setup... Nextcloud will now create the database and fill the data folder with demo file
    • You might see error 504! Just wait and try again later browsing to http://YOUR_DISKSTATION/nextcloud until you see a login screen

Optional: Remap Web Station root directory

In case Nextcloud is the only web page running in your Web Station you might want to change the root folder from /volume1/web to /volume1/web/nextcloud

  • cd /var/services
  • rm web (default a soft link to /volume1/web)
  • ln -s /volume1/your share/new www root/ web