Guide for installing Owncloud 9 to Synology NAS running DSM 6

OwnCloud in Synology NAS

Owncloud is among the best things the open-source communities have produced. This guide will have detailed instructions for installing Owncloud 9 to Synology NAS device with DSM 6.

Some prewords:

  • At the time of this guide, DSM 6 is release candidate (rc) version
  • This is fresh install – no upgrade from existing owncloud version. If you are planning to do upgrade, please see my other blog post about Owncloud upgrade procedure and the things you should consider when doing the upgrade.
  • DSM 6 allows sudo to other users (root, http) in ssh terminal (with NAS admin password), it just makes many things easier (thanks Synology!)
  • I will be installing owncloud manually, so no synocommunity packages or install procedure is used
  • It is possible to install Redis server and php extension php-redis to your Synology NAS, in order to support file locking in owncloud. Please see my other blog post for installing phpredis into Synology NAS.
  • I’m assuming that you have enabled web station, SSH, installed PHP and Mariadb/phpMyAdmin and know what is Apache – in your Synology NAS. I’m also using scripts to automate permission assignments in SSH terminal sessions.
  • If you haven’t hosted any websites in your NAS earlier, please enable webstation package and test that PHP websites are working in your setup – through WAN 0r LAN, depending what are your plans on owncloud usage.  As minimum requirement use phpinfo() or similar PHP powered web page before jumping into Owncloud installation. This ensures you have your firewalls, web servers, virtual hosts etc. configured correctly.
  • My web root in this example is located in: /volume1/web/
    • If you have it in different location, please modify any scripts or examples given here accordingly.

 

Ok -let’s get started with the installation.

1)  Download the latest stable ZIP file from owncloud.org (https://owncloud.org/install/) and copy extracted Owncloud folder to your Synology web root.

Download Owncloud server files

And here is the folder structure how it should look in ‘/web/owncloud/’:

kuva1c2)  Create empty owncloud data folder outside web folder, as recommended by Owncloud community  (I created it at: /volume1/owncloud/)

Note: If you decide to take this recommendation and setup your Owncloud data folder outside the web folder (makes upgrades, backups etc. easier) –  you have to make some additional configurations to your PHP settings in Synology admin UI. However – these changes are valid only if you want to access your Owncloud through Synology hosts from the WAN side.

There are 2 options to make the change required (otherwise php/Owncloud instance cannot access your data folder outside web folder):

Option a)

Append your PHP open_basedir configuration with the location of your Owncloud data folder (IF outside web folder):  ‘:/volume1/owncloud’

(Note: Do not delete any existing paths, add it to the end of the existing configuration – see screenshot)

Synology Admin UI -> Main Menu -> Web Station -> PHP Settings ->

opendir

If you choose option a – it is highly recommended in Owncloud hardening guide to update path [/dev/urandom] there also, see for the example in the provided screenshot above. Based on my personal experience, I’ve also disabled PHP cache here and I’m using Redis server for Owncloud caching.

OwnCloud uses a RFC 4086 (“Randomness Requirements for Security”) compliant mixer to generate cryptographically secure pseudo-random numbers. The random number generation also tries to request random numbers from /dev/urandom, thus it is highly recommended to configure your setup in such a way that PHP is able to read random data from it.

Option b)

Clear the whole open_basedir input box, and while keeping the customize option still checked, apply changes. This will disable global PHP open_basedir execution restrictions completely. You can still assign any site/host specific open_basedir restrictions using the .user.ini files approach in docroot folders for every host required.

This option b where open_basedir is disabled for Owncloud – is actually the recommended approach by Owncloud documentation if Owncloud is running in 32bit environment.

3)  Assign following permissions to folders for installation purposes. I run it using a script (.sh) file (remember to execute from system root!), with following contents:

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

chown -R http:http /volume1/web/owncloud/
chown -R http:http /volume1/web/owncloud/apps/
chown -R http:http /volume1/web/owncloud/config/
chown -R http:http /volume1/web/owncloud/themes/
chown -R http:http /volume1/owncloud/

chown http:http /volume1/web/owncloud/.htaccess

find /volume1/web/owncloud/ -type f -print0 | xargs -0 chmod 777

find /volume1/web/owncloud/ -type d -print0 | xargs -0 chmod 777
find /volume1/owncloud/ -type d -print0 | xargs -0 chmod 777

chmod 777 /volume1/web/owncloud/.htaccess

And I’m running it in SSH terminal like this (run it as root as it “can be done in DSM 6″ and from root folder in SSH terminal):

Kuva2b

4)  Enable Virtual host in NAS for the new owncloud folder in your web root.

Kuva3

I would highly recommend you choose Apache 2.2 as your webserver for your Owncloud virtual host. Mainly because it works out-of-the-box for most users in Owncloud / Synology NAS setup. Apache 2.4 has been reported not to work in recent comments received from users, and Nginx will require more configuration, especially the re-write rules might prove to be challenging (some users have reported 404 not found error after installation). So just choose Apache…!

5)  Double check that you know your Mariadb/MySQL root password – you will need it during owncloud setup/installation.

6)  Point your Web browser to the newly created Owncloud website/portal – and finalize installation. Please use the web address that you want to use when using Owncloud, so that during installation your domain will be automatically added to allowed domains in Owncloud config.php file. Please give Admin password and give other details.

Kuva47)  Give needed details for installing Owncloud. Highly recommended settings:

1.  That you use MySQL/MariaDB – give database details needed
2. Define your Owncloud DATA folder to be outside the Web folder for Owncloud

Kuva4c8)  After installation the Owncloud web interface should open.

Kuva5If you see the error “There were problems with the code integrity check” – this is most likely because Synology creates @eadir cache folders everywhere. Removing these manually from Owncloud folders will remove the error. In this job you might find this code useful:

Select Code
1
find . -name "@eaDir" -type d -print0 | xargs -0 rm -rf

And here is example on how to use it:

kuva_remove_eadirs
And you have now removed all ‘@eaDir’ folders from owncloud folders. And you should also be able to remove the error by Selecting ‘RESCAN’ on admin page of Owncloud.

kuva_remove_eadirs_check9)  After installation you need to assign more strict folder permissions back for Owncloud folders. Please regard the given script as example only – always validate security permissions for your needs as required – and review related documentation from Owncloud.org for version 9.

I use a script (.sh) file, with following contents:

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

chown -R root:http /volume1/web/owncloud/

chown -R http:http /volume1/web/owncloud/apps/
chown -R http:http /volume1/web/owncloud/config/
chown -R http:http /volume1/web/owncloud/themes/

chown root:http /volume1/web/owncloud/.htaccess
chown root:http /volume1/owncloud/.htaccess

find /volume1/web/owncloud/ -type f -print0 | xargs -0 chmod 0640
find /volume1/owncloud/ -type f -print0 | xargs -0 chmod 0640
find /volume1/web/owncloud/ -type d -print0 | xargs -0 chmod 0750
find /volume1/owncloud/ -type d -print0 | xargs -0 chmod 0750

chmod 0644 /volume1/web/owncloud/.htaccess
chmod 0644 /volume1/owncloud/.htaccess

And I’m running it in SSH terminal like this (run it as root as it “can be done in DSM 6″ and from root folder in SSH terminal):

Setup permissions for use

If you want to be able to edit the ‘max upload size’ section in Owncloud admin area, you might want to consider also having following permissions in place (upload size is overrided in hidden ‘.user.ini’ file in Owncloud root):

Select Code
1
chown http:http /volume1/web/owncloud/.user.ini

This makes the file writable by ‘http’ user, thus editable in Owncloud admin section.

10)  Double check that permissions got assigned correctly. You can also safely remove ‘data’ and ‘@eaDir’ folders inside ‘/web/owncloud/’ – they are not needed inside there if you created data folder outside the web folder as instructed:

Kuva811)  Done – You have successfully installed Owncloud 9 to your Synology NAS.

Owncloud running in Synology NASPlease follow closely Owncloud.org and Owncloud Github for further configuration, setup and any other topical issues. There are million things still to configure in your Owncloud setup including config.php modifications etc. 

Note:  It is possible to install Redis server and php extension php-redis to your Synology NAS, in order to support Redis caching and file locking in owncloud. Please see my other blog post for installing phpredis into Synology NAS  running DSM6 without bootstrapping. Also I have posted a guide on how to configure Owncloud to use system CRON in Synology NAS (DSM 6 RC).

(update 28.3 2016 – cleaned permission scripts and made addition about PHP open_basedir config required if data folder outside Owncloud web folder)

(update 13.6 2016 – Updated Apache as the preferred webserver for the virtual host configuration in Synology NAS. Mainly because Apache works out-of-the-box. Nginx actually requires more configuration – especially the re-write rules may cause headache and 404 not found -errors.)

(update 14.2 2017 – Updated Apache 2.2 as the preferred webserver version for the virtual host configuration in Synology NAS, due to multiple users reporting issues when using Apache 2.4 with latest Owncloud and DSM versions.)

Feedback

Juha Ketola

Juha Ketola

Author is a passionate IT enthusiast and early adopter. Packed with years of experience leading Enterprise level IT development teams within the biggest companies of Technology industry. Watches closely start-ups and new disruptive innovations in order to stay on the cutting edge. Embraces hands-on IT development and IoT.
Juha Ketola
Link to open Linkedin Profile

170 Responses to Guide for installing Owncloud 9 to Synology NAS running DSM 6

  1. Christian says:

    Hi

    I tried to install owncloud with this nice tutorial.
    I created the database and configured it likewise.
    When owncloud is restarting , after configuring, the site claims it can’t find a file:
    File not found
    The document has not been found on this server.
    Click to go back.

    Das anyone have a clue?

    thanks in advance
    Christian

    • Christian says:

      I’m sorry. I frgot to mention that the site is looking at:
      10.0.0.149/index.php/apps/files/

      It results in file not found

      • Juha KetolaJuha Ketola says:

        Switching to use Apache 2.2 might fix this issue. Compliments to users reporting this fix.

  2. Juha KetolaJuha Ketola says:

    Hi,

    Those who are having some error after latest update, can you post your details also:
    – DSM version
    – PHP version (webserver)
    – Webserver in use
    – Owncloud version in use

    I have not seen this error, so I try to replicate this some day if I just have the time…..

    • Christian says:

      Hi Juha,

      Thanks for your reply.

      – DSM version – DSM 6.0.2-8451 Update 9
      – PHP version (webserver) – 7.0
      – Webserver in use – Apache 2.4
      – Owncloud version in use – 9.1.3

      until step 7 It went well
      At step 7 I created a different user and password.
      (I checked PHPMyAdmin and a database has been created.)

      After some time my webpage returned the comment:
      Service Unavailable
      The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

  3. Stefan says:

    I’ve tried this – and later it works.
    Problem: I’ve installed apache 2.4 – only 2.2 works today (Feb 2017)
    And this has to be setup in webstation -> virtual host and not in webstation -> settings!
    using php 7.0 seems to work, but not fully tested…

    • Benoit says:

      I confirm there is an issue with DSM 6.0 + Apache 2.4 and Owncloud 9.
      With a full functional installation, I tried to migrate from Apache 2.2 to 2.4 without success. Other website managed on the same NAS seems to work with the migration.

    • Juha KetolaJuha Ketola says:

      Thank you both for confirming this!!

  4. Juha KetolaJuha Ketola says:

    Excellent comments – thanks for the updates!!!
    So it seems Apache 2.2 should be used for the time being for hosting Owncloud in Synology NAS.

    I will add a note to the post about this.

  5. Raphaël says:

    Hi Juha,
    Thanks for your tutorial !

    I followed all steps of installation, and arrived to the configuration step (enter the admin account, MySql informations…). Then I validate.
    And get the “File not found – The specified document has not been found on the server. You can click here to return to ownCloud” message. I can’t find anything helpfull to resolve this :'(

    I don’t even know what to test or what folder’s right to change to succeed !

    Thanks for your help !

    Raphaël

    • Raphaël says:

      Ok, I read your last comment to late : with Apache 2.2 has to be in used to succeed the install of owncloud.

      Thanks again ^^

    • Juha KetolaJuha Ketola says:

      Hi Raphaël!

      Thanks for confirming and leaving your comment.
      Appreciated!

      Take care!

  6. Tom says:

    Hi there,
    Thank you for sharing this tutorial.
    I am about to try tonight but I do have a basic question first: it is possible to have several “instances” of ownCloud, like if you would like to work on several projects with different “content databases”?
    Cheers,
    Tom

    • Juha KetolaJuha Ketola says:

      Hi!

      It should be ok as per my understanding to have multiple instances on same server. Just make sure you have separate installation folders, databases, data folders and domain names in use. And make sure there are no shared files between the instances, like config or log files, and you should be fine.

      If you ever run into issues, please check disabling any potential cache services first. That is the area where might some hiccups with some cache services come based on my experience. But this might be rather rare issue anyway.

      Hope this helps anyone interested in same topic. Thanks for asking! Take care!

  7. Stephane says:

    Works great with owncloud 10.0.2 and DSM 6.1.1-15101 Update 4
    Just had to tick php modules :
    curl, gd, iconv, mysqli, pro_mysql, posix and zip

    Thanks a lot for auto

  8. Magix says:

    Hi. Thanks for the tuto. Works fine also with the 10.0.3.3 version.
    The only thing is that the app does appear as installed in the synology package center.
    Any idea?
    Thank you

    • Magix says:

      >Correction: The only thing is that the app does NOT appear as installed in the synology package center.
      Any idea? Plz

  9. Anonymous says:

    Hi,

    when i tried to configure the mariaDB the follow errors occured

    SQLSTATE[HY000] [2002] No such file or directory

    may i know how do i resolve this please.

    • Anonymous says:

      Same here. Using MariaDB 10 and Owncloud X. PHP 7.0 for Owncloud virtual host. And Apache 2.2.
      Tried to change into PHP 5.6 for OC virtual host, did not solve the problem.

      • vitar says:

        I had the same issue (SQLSTATE[HY000] [2002] No such file or directory)…

        Finally helped to change the name ‘localhost:3307’ to IP equivalent ‘127.0.0.1:3307’ in MariaDB destination field on OC initialization screen.

        Just to keep the track:
        Before I unsuccessfully played a bit with legacy linking as mentioned here: https://github.com/SynoCommunity/spksrc/issues/2136 (I found my ‘mysql’ located here: /volume1/@appstore/MariaDB10/usr/local/mariadb10/bin/mysql)

        I also checked that there is no ‘skip-networking’ option in my.cnf file (it was not) and I added a line ‘httpd: ALL’ to /etc/hosts.allow file just to try as mentioned here: http://www.wolfcms.org/forum/topic1101.html by butchler (post no. 9).

        DS214j, Apache 2.2, PHP 7.0, MariaDB10, OC 10.0.9

        Thanks a lot for the unique tutorial, Juha!
        Vit Rapcan, Czech Republic

  10. Stefan says:

    I just decided to put Raspberry PI with NFS to Synology and run OwnCloud that way. 🙂

  11. Gabriel says:

    Hi Juha,

    I followed you user guide and everything works great.
    I want to access my station DS216play via samba/cifs and I cannot make the color dot green. I can access it via Webdav but it much slower that samba.
    Any hints are appreciated. I google it, but nobody give a clear solution for Synology.

    Thank you in advance
    Gabriel

  12. Justin Cooper-Marsh says:

    is it possible to reset the admin password

    the command “sudo -u http php /volume1/web/owncloud/occ user:resetpassword admin”

    generates the following issue

    PHP module intl not installed.
    Please ask your server administrator to install the module.

    PHP module GD not installed.
    Please ask your server administrator to install the module.

    An unhandled exception has been thrown:
    exception ‘Exception’ with message ‘Environment not properly prepared.’ in /volume1/web/owncloud/lib/private/Console/Application.php:135
    Stack trace:
    #0 /volume1/web/owncloud/console.php(105): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #1 /volume1/web/owncloud/occ(11): require_once(‘/volume1/web/ow…’)

    GD and intl seem to be bundled.

    • Justin Cooper-Marsh says:

      fixed it

      cp /volume1/@appstore/PHP5.6/usr/local/lib/php56/modules/gd.so /usr/lib/php/modules/.
      cp /volume1/@appstore/PHP5.6/usr/local/lib/php56/modules/intl.so /usr/lib/php/modules/.



Leave a Reply

css.php