Guide for installing Owncloud 9 to Synology NAS running DSM 6

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.

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 pagebefore 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.

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.

(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 ->

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:

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):

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

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.

If 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:

1

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

And here is example on how to use it:

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.

9) 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.

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):

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):

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:

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 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

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.

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.

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…

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.

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 !

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

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!