OwnCloud

From QNAPedia
Revision as of 19:41, 26 October 2015 by Glenn (talk | contribs) (catchg)
Jump to navigation Jump to search

ownCloud Introduction

ownCloud has some interesting features, that QNAP is currently missing out of the box:

You can use it as a home based drop-in replacement for cloud file services like Dropbox or Google files. You can share files between different user accounts using a web frontend or the WEBDAV protocol (although this only makes sense when exposing QNAP to the Internet or using a router with VPN functionality).

Even when not accessing your NAS from the Internet: QNAP currently lacks a calendar and address book server. Since most home users do not own an Exchange server, ownCloud is an easy way to add such functionality to the QNAP NAS.

  • You can share (fully read and write) a calendar and address book between different devices and computers at home (Most smartphones, mail and calender clients on Windows, Linux and Mac support calDAV and cardDAV protocol)
  • You can use this to automatically backup the contacts and calendar data of your smartphone onto your NAS, everytime your smart phone is in range of your WLAN
  • You can create extra calendars and address books that you share between accounts of different family members


More informations e.g. at the ownCloud home page or en.wikipedia.org/wiki/OwnCloud

OwnCloud supported QNAPs

Owncloud V5

Update to a recent QNAP firmware, to make sure to have PHP >= v5.3 on your QNAP.

  • If in doubt, find out the the current PHP version of your QNAP on the SSH terminal prompt: /mnt/ext/opt/apache/bin/php --version

Reported to run on:

  • TS-110
  • TS-119
  • TS-212
  • TS-219
  • TS-220
  • TS-439 Pro
  • TS-439 Pro II+
  • TS-659 Pro

Should work with:

  • QNAPs with firmware V4.0.0 or higher, probably all >V3.7 firmware versions, all QNAP firmwares with PHP >=V5.3
  • TS-x10 series (TS-110, TS-210, TS-410)
  • TS-x12 series (TS-112, TS-212, TS-412)
  • TS-x19 series (TS-119, TS-119P+, TS-119P+, TS-219, TS-219P+, TS-219P II, TS-419, TS-419P+, TS-419P II)

Reported NOT to work

  • TS-x09 series (TS-109, TS_209): QNAP firmware support seems to have stopped at version 3.3.x, that firmware version does not contain PHP >=V5.3
  • reported fix: install libtool package (ipkg install libtool), but some still have trouble with "Cannot load /opt/lib/libphp5.so into server: /opt/lib/libphp5.so: undefined symbol: unixd_config"

Owncloud V6

Note: Requires different customization of php.ini than v5 (see preparation section)

Owncloud V6 reported to run on

  • TS-119 (Firmware v4.0.5)
  • TS-212 (Firmware v4.0.2)
  • TS-219 PII (Firmware v4.1.0)
  • TS-269L (Firmware v4.0.5)
  • TS-439 Pro II+ (Firmware v4.1.0 beta)
  • TS-469U (Firmware v.4.0.1)


Owncloud V7

Note: Requires different customization of php.ini than v5 (see preparation section)

Owncloud V7 reported to run on

  • TS-219 PII (Firmware v4.1.0)

Preparations: Required clients

e.g. have these on your client computer to perform some of the following steps

  • Putty
  • WinSCP

Preparing QNAP services for Owncloud

Enabling Web server, PHP and SFTP

Login to the admin GUI of your QNAP (e.g. [http:// http://]<your_qnap_ip>:8080)

  1. Under System Administration / General settings, ensure that the admin console is not using port 443 for SSL (use a different port e.g. 4431). Some clients cannot access Owncloud properly, if owncloud cannot use port 443 for SSL (e.g. the iPhone CardDAV Client), therefore the admin console should not block port 443.
  2. Under Network Services, enable Telnet/SSH
    - You don't need Telnet connection, just allow SSH connection on port 22 (default)
    - Enable SFTP to be able to copy files later on
  3. Under Network Services, enable Web Server
    - Preferably set port 80 and port 443 for SSL configuration
    - Check by opening [http:// http://]<your_qnap_ip> and [https:// https://]<your_qnap_ip>
  4. On the same page at the bottom of the Web Server config page, under the section "php.ini Maintenance", click the check box and then select "edit" in the now appearing drop down field. Find the php.ini line "magic_quotes_gpc" and make sure it says "Off", not "On". Otherwise OwnCloud may complain about this later on. Don't forget to click "Apply" when done.
    Warning: In at least QNAP firmware 4.0.5 you may need to edit php.ini from WinSCP or SSH instead, since the the graphical "php.ini Maintenance" - Edit button in the Web admin GUI seems to have a bug (at least in firmware 4.0.5 the GUI may only show incomplete parts of the "php.ini" config file). You can find php.ini with WinSCP in "/mnt/HDA_ROOT/.config/php.ini", the actual path may vary on your QNAP).
  5. Now SSH-connect to your QNAP using Putty (with username:admin). Note that due to a custom version of SSH on QNAP, you may not be able to use other accounts than "admin" for SSH connecting. On the SSH terminal prompt, run "/mnt/ext/opt/apache/bin/php --version" to find out the version of PHP your QNAP is currently running
  6. Upgrade PHP 5.3: If your QNAP 's PHP version is not 5.3. or higher and their is no recent firmware update available, you need to manually install PHP for Owncloud.


Additional PHP preparation for ownCloud V6 and V7

Installing ownCloud v6 and v7 needs a few more QNAP customizations:

1. QNAP config - Adding ownCloud directory to "apache.conf"

  • Verify your QNAP uses Apache v2.2, by running this SSH command: /usr/local/apache/bin/apache -v
    If your QNAP uses a different version, consult the owncloud documentation.
<Directory [pathofWEBshare]/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>


2. QNAP config - Disable "eaccellerator" in php.ini (only required if owncloud will be installed using MySQL instead of the default SQLite)

You may need to do the following from WinSCP or SSH, the graphical "php.ini Maintenance" - Edit button in the Web admin GUI at least in firmware 4.0.5 has a bug and will only show incomplete parts of the "php.ini" config file

  • Locate php.ini (/mnt/HDA_ROOT/.config/php.ini, path may vary on your QNAP)
  • Edit php.ini and change the eaccelarator filter line to point to the owncloud installation. This will stop caching the owncloud data. 
[eaccelerator]
extension = eaccelerator.so
eaccelerator.shm_size = 32
eaccelerator.cache_dir = /.eaccelerator.tmp
eaccelerator.enable = 1
eaccelerator.optimizer = 1
eaccelerator.check_mtime = 1
eaccelerator.debug = 0
eaccelerator.filter = "/share/MD0_DATA/.qpkg/owncloud/owncloud"
eaccelerator.shm_max = 1M
eaccelerator.shm_ttl = 0
eaccelerator.shm_prune_period = 3600
eaccelerator.shm_only = 0
eaccelerator.compress = 1
eaccelerator.compress_level = 9
  • OR
[eaccelerator]
extension = eaccelerator.so
eaccelerator.shm_size = 32
eaccelerator.cache_dir = /.eaccelerator.tmp
eaccelerator.enable = 1
eaccelerator.optimizer = 1
eaccelerator.check_mtime = 1
eaccelerator.debug = 0
eaccelerator.filter = "/share/CACHEDEV1_DATA/.qpkg/owncloud/owncloud"
eaccelerator.shm_max = 1M
eaccelerator.shm_ttl = 0
eaccelerator.shm_prune_period = 3600
eaccelerator.shm_only = 0
eaccelerator.compress = 1
eaccelerator.compress_level = 9
  • then restart Apache service on SSH prompt: /etc/init.d/Qthttpd.sh restart


(Disabling the "eacceleator" was reported in http://forum.owncloud.org/viewtopic.php?f=26&t=18476, to fix v6 installation problems)

Install ownCloud

Before you start:

  • Make a backup of your NAS before you start installing anything
  • Be careful with chmod and chown, to not messup other folders of your NAS
  • Maybe read the description first and determine the location of your web server's folder, of the "pwauth"command and the full path of your data share before starting the installation.


To do
Explanation
Download
  1. tar.bz2 from http://www.owncloud.org/install
  2. Unix user backend from http://apps.owncloud.com/content/show.php/?content=148406

tar.bz2 is all PHP files of ownCloud.

The unix user backend plugin will enable user accounts of your NAS inside the ownCloud application

Locate the folder of the web server of your NAS

  • WEB=/share/HDA_DATA/Qweb

The base folder may vary, depend on your NAS version, e.g:

  • /share/HDA_DATA/Qweb
  • /share/Web

Install ownCloud

  • Upload the .bz2 file to any folder on your NAS and run:
  • tar -xjf owncloud-*.tar.bz2 -C $WEB/owncloud

You should now have an "owncloud" folder in your web server directory

(You may remove the .bz2 file when done)

Install the Unix user backend app

  • unzip user_pwauth.zip and upload the folder "user_pwauth" to $WEB/owncloud/apps
The "unzip" command on your NAS may be too old to be able to unzip the ZIP archive, therefore unzip it before uploading
Change owner and permissions of the owncloud app folder
  • chown -R httpdusr:administrators $WEB/owncloud
  • chmod -R 770 $WEB/owncloud
Now only 'httpdusr' (the account of the QNAP webserver) and all admins have access to the binary files.

If you do not want to store data in the default folder (owncloud/data/), you can create a custom data folder:

  • DATA=/share/HDA_DATA/[shareName]
  • mkdir -p $DATA/owncloud/data
  • chown -R httpdusr:administrators $DATA/owncloud
  • chmod -R 770 $DATA/owncloud

Instead of "[shareName]" enter the name of a share on your NAS. This is where the user generated content gets stored.

You can use an existing share, create a dedicated share or use the WEB share (maybe it is best to create a dedicated share for ownCloud's data)

The path prefix (/share/HDA_DATA) may be different on your NAS version!

It is possible to change the default data path later on in the config file "owncloud/config/config.php"

Setup ownCloud 1/2

  • Call https://[your_nas]/owncloud
  • Create Admin Account: ocadmin
  • Select "Advanced" and relocate the data folder to the previously created data folder:
    /share/HDA_DATA/[share]/owncloud/data
  • Choose SQLite as database

When started for the first time, owncloud will show a config screen.

Pick a name for the ownCloud admin account, that is different from the admin account of your NAS (This simplifies using the Unix user backend)

SQLite is sufficient for home grown installations (it is embedded into PHP), otherwise you need to activate the "MySQL" service on QNAP (which takes extra RAM)

Setup ownCloud 2/2

  • Login to ownCloud as ocadmin
  • In V5, go to menu ocadmin/apps. In Owncloud V6 use the "Apps+" button in the bottom left corner of the screen)
    - Enable the App "Unix user backend"
  • go to menu ocadmin/admin
    In the section 'Unix Authentication':
    - Change the path of pwauth executable to:
    /mnt/ext/opt/apache/bin/pwauth
    - Change list of auth uids to: 0-10000
  • go to menu ocadmin/users
    in the groups column, add the root admin of your NAS (usally called 'admin)' to the group 'admin'
  • The path of "pwauth" may be different on your NAS. Usually it is in the apache folder.
  • When done, you should be able to list all your NAS user accounts also in the ownCloud users list.

You are now done with the installation and should now be able to access ownCloud with any of your QNAP NAS accounts.

More details: owncloud.org/install

Fixing installation errors

  • Mysterious PHP errors appear: Reread the compatibility section and check that your NAS PHP version satisfies the requirements
  • Owncloud complains about "magic quotes": See the section about preparing your NAS web server, you missed the config option in php.ini
  • Owncloud complains about wrong file permissions: recheck the section about "chmod" and "chown". Usually the error message also tells, whether you missed permissions on the installation folder or the data folder
  • The admin config section 'Unix Authentication' is missing: This means, the ownCloud app 'Unix user backend' was not copied/installed or is disabled.
  • Login fails: The path to "pwauth" may be wrong. If in doubt, use putty/Winscp to verify "pwauth" is really located at the supposed file path.
  • Login fails: The auth uid range of the "Unix Authentication" may be still default
  • Backup problem: You cannot access the files in the data folder: use an admin user account to backup the data folder
  • Owncloud v6 installation stalls, when trying to create the admin user: Recheck the additional QNAP PHP preparation section for Owncloud6 and make sure that apache is restarted after these changes.


Start all over

If you got lost in installation, delete/move/rename the following folder, before retrying:

  • $WEB/owncloud
  • $WEB/owncloud-xxxxxxxxxxx
  • $DATA/owncloud

Then restart from scratch


You may also reset your php.ini to the default values, if you have messed up preparation:

In QNAP Admin GUI -> Applications -> Web Server -> php.ini Maintenance -> "Restore"



Checking log files

  • The web server of your NAS usually has log files activated that can assist in fixing installation bugs. The log folder location may yary on your NAS, e.g. try
    /mnt/ext/opt/apache/logs
  • onwCloud also has a log file, per default it is in the data folder that you have chosen, e.g.
    /share/HDA_DATA/[shareName]/owncloud/data/owncloud.log
    If you are able to access the admin config web page of ownCloud, you can increase the log level by setting the log level to "info" or "debug".


Optional ownCloud customizations

(These are optional tasks to customize ownCloud for better usability)

SSL & Redirect (pshankland 28/06/2012)

If you are going to use your QNAP ownCloud installation for business, you will probably want to deploy SSL certificates signed by an official authority and maybe redirect the "/owncloud/" URL to "/".

Howto: Using custom SSL certificate and configuring redirects for Owncloud on QNAP

Accessing OwnCloud

To access ownCloud from a browser, use "http://[yourNAS]/owncloud" or "https://[yourNAS]/owncloud"


To access ownCloud cardDAV addressbooks from applications, it gets a bit overwhelming. Currently there seems to be quite a range of URL choices:

  1. "http(s)://[yourNAS]/owncloud/remote.php/carddav" (seems to work in iOS without the leading http(s):// )
  2. "http(s)://[yourNAS]/owncloud/remote.php/carddav/principals/[accountname]"
  3. "http(s)://[yourNAS]/owncloud/remote.php/carddav/principals/[accountname]/[addressbookname]"
  4. "http(s)://[yourNAS]/owncloud/remote.php/carddav/addressbooks"
  5. "http(s)://[yourNAS]/owncloud/remote.php/carddav/addressbooks/[accountname]/[addressbookname]" (seems to work in Thunderbird SOGO plugin)
  6. You can autogenerate such a link in owncloud "Settings" menu of the address book (click the world symbol)

(It looks like it depends a bit on the client, which URL will work)


To access ownCloud calDAV calendars from applications, it gets a bit overwhelming. Currently there seems to be quite a range of URL choices:

  1. "http(s)://[yourNAS]/owncloud/remote.php/caldav" (seems to work in iOS without the leading http(s):// )
  2. "http(s)://[yourNAS]/owncloud/remote.php/caldav/principals/[accountname]"
  3. "http(s)://[yourNAS]/owncloud/remote.php/caldav/principals/[accountname]/[calendarname]"
  4. "http(s)://[yourNAS]/owncloud/remote.php/caldav/calendars"
  5. "http(s)://[yourNAS]/owncloud/remote.php/caldav/calendars/[accountname]/[calendarname]"
  6. You can autogenerate such a link in owncloud "Settings" menu of the calendar (click the world symbol)
  7. The settings menu of calendar shows some URL hints

(It looks like it sometimes depends a bit on the client, which URL will work)


At least iOS seems to require port 443 to get SSL to work properly for calDAV and cardDAV.


Things to keep in mind

  • Hardisk spindown: Depending on your preferences: if e.g. you are using a cardDAV client from an [x]pad or mobile device to connect to your Owncloud service, you might want to set the client config to load/refresh its data manually and not "auto poll every 15min". Otherwise this could prevent your NAS harddisk from going to sleep mode. This might also apply to other "always on" clients that poll your Owncloud service on a scheduled basis.
  • Backup: Ensure that the DATA folder created previously is backed up within your backup schedule
  • Uninstall: If you want to uninstall ownCloud, just delete the WEB/owncloud folder (and the DATA/owncloud folder, if you don't need the data anymore)
  • Version: To find out the installed version number of owncloud, call
    https://[yourNAS]/owncloud/status


Issues regarding moving existing addressbooks to owncloud:

  • Currently ownCloud only seems to be able to import/export vCards (.vcf) contact files. At least you can import several vcf Files with a single click in contact settings.
  • Outlook(>2007) can import/export vCards (attach contacts to a mail to generate vCard files, e.g. see this <a href="http://stackoverflow.com/questions/208890/export-all-contacts-as-vcards-from-outlook">trick</a>). Outlook 2003 seems to have a bug to only export the first email address to a vcard.
  • Thunderbird needs an external plugin (e.g. "SOGO" plugin) to access cardDAV address books. Thunderbird 17.0.5 also has an issue, if multiple mail address values are in the same field.
  • eM Client seems to be a good client pick for Windows: has no problems with multivalue eMail addresses and seems to have quite some address import/export capabilities, the free version allows up to 2 accounts.
  • iOS has native cardDAV support in v>5
  • Android seems to require an extra app to sync contacts using cardDAV
  • More cardDAV and calDAV clients: http://en.wikipedia.org/wiki/Comparison_of_CalDAV_and_CardDAV_implementations


IOS 7 CardDAV Bug

IOS: There is a CardDAV Setup bug in iOS7. Apple is informed, no date for an update is communicated so far.

When adding/editing a cardDAV configuration, iOS7 most often saves the cardDAV URL in the wrong format:

  • <yourNAS>/remote.php/carddav/principals/<useraccount>//remote.php/carddav/principals/<useraccount>/

or

  • <yourNAS><yourNAS>/remote.php/carddav/principals/<useraccount>/

instead of

  • <yourNAS>/remote.php/carddav/principals/<useraccount>/


Here is how to fix that bug in the iOS7 device:

Either add a new configuration:

  • Add CardDAV (others) / Account
  • As "Server" enter: <yourNAS>/remote.php/carddav/prinicipals/USERNAME (don't add http:// or https:// in front of <yourNAS>)
  • enter "User name", "Password" and a "Description" as required
  • then tap "Next" to proceed

If you want to fix an existing cardDAV configuration, open that existing configuration.


Now click on "Advanced settings" of the cardDAV configuration, to edit the "Account URL". Due to the bug, the URL has been garbled by IOS (as written above). Now this needs to be corrected manually:

  • Change the Account URL to its correct form "<yourNAS>/remote.php/carddav/prinicipals/<username>/"
  • Either activate "Use ssl" and enter port 443 - or deactivate SSL and use port 80
  • Now you have fixed the URL, but still need to convince iOS that this is a correct configuration.
  • Tap "<" to close the "Advanced settings"
  • Tap "Done" on the main screen for the first time, to attempt to save the changes.
    If using SSL, iOS will now whine about: "Cannot connect using SSL. Do you want to try setting up the account without SSL" - [Continue] - [Cancel].
    Be sure to tap "[Cancel] on that screen!
    Further on, iOS will whine about "Contacts Account. Unable to verify account information - [OK]".
    Just tap "[Ok]".
  • Now tap "Done" a second time:
    iOS will be even more heart-broken and weep "This account may not be able to sync contacts. Are you sure you want to save? - [Save] - [Edit]". Confirm this by tapping "[Save]".
  • iOS will now finally save the changes!
  • To verify the cardDAV configuration is working, open any app, that is using contacts.
  • If your "ownCloud" configuration seems correct, but does not appear in the contacts section of that app, double tap the iOS menu button and close the app and then restart the app. That should refresh the contact configuration of that app.

Note that due to this bug, its difficult to distinguish between correctly and incorrectly entered cardDAV configuration, since iOS 7 will never give a confirmation about correctly entered cardDAV configuration. And it will always complain as mentioned, no matter if the configuration is correct or not correct.


Workaround first published by Rene: http://blog.renesasse.de/ios7-carddav-bug-hier-im-zusammenhang-mit-owncloud-carddav/