Home » Blog » Software Development » Your own cloud server with Owncloud on the Raspberry Pi

Your own cloud server with Owncloud on the Raspberry Pi

The management, synchronization, and sharing of files, calendar information, address book data, music, and photos is widely used nowadays. It is offered by many (often freely available) cloud-based services like Dropbox, Sugarsync, Flickr, Picasa and many others. The big players like Apple, Google, and Microsoft also offer multiple of these services and people can use all of these with just a single account. While these “free” services might be very comfortable the not-so-free part of all these services is that your most private data is actually stored on servers that are not under your direct control and your data is often also used to generate an advertisement profile of you. If you want to have your data on your very own piece of hardware right under your control Owncloud might be an interesting option for you. It offers all the nice services like CalDAV, CardDAV, and WebDAV, which allow for managing your calendars, contacts, music, photos, and files in general in your own cloud. In the following, I give a brief overview about the steps that are needed for an installation and I present a setup script that automates the whole installation and update process. The same script can later be used for updating your Owncloud installation.

Here is an overview about the steps that are needed for installing Owncloud on a freshly installed image:

  1. Update and upgrade APT packages
  2. Make sure that the group www-data exists
  3. Install all needed packages, e.g., Apache, PHP, SQLite
  4. Perform firmware update with 240 MB RAM, and 16 MB video
  5. Generate self-signed certificate (that is valid for one year here) to be used for SSL connections
  6. Enable Apache modules that are needed by Owncloud
  7. Disable unneccessary (for Owncloud) module(s) to lower the needed resources
  8. Configure Apache to use self-signed certificate
  9. Enable SSL site
  10. Limit the number of parallel Apache processes
  11. Resize the swap file to 512 MB
  12. Download and install the latest Owncloud release
  13. Change group and owner of all /var/www files recursively to www-data
  14. Finally, restarts the Apache service

I set up a script that automates these steps and gives you a ready-to-use installation of Owncloud. You can find the script in my Github repository. This script was tested on the Raspbian distribution from 2012-07-15.

First of all, make sure that Git is installed:

[gist id=3358189]

Then you can download the latest PiCloud setup script with

[gist id=3358194]

The script is executed with

[gist id=3358196]

The initial screen should then look like this:

PiClouseSetup

Parts of the steps done by the script were inspired from this blog.

I hope that this script is of some help for some people. I would be happy to get feedback or comments!

UPDATE: I added the possibility to use the NGiNX webserver instead of Apache . The NGiNX server does not use as many resources as the Apache and, thus, should run faster. The updated script can be found in the repository.

WebDAV access (also for iOS)

You can acccess your Owncloud instance via WebDAV by using the URL

https://yourServerUrl/owncloud/remote.php/webdav/

together with your chosen user name and password.

Synchronizing with iOS

If you want to synchronize your calendar(s) and your contacts of your iOS device(s), these I formation might be of note rest for you. It seems that there are still some (documentation) issues with the official Owncloud wiki about the needed iOS settings. These settings, at least, work for me with the NGiNX installation:

Calendar (CalDAV)

Server: https://my.servername.com/owncloud/remote.php/caldav/principals/USERNAME/
SSL enabled, port 443

Contacts (CardDAV)

Server: my.servername.com:443/owncloud/remote.php/carddav/principals/USERNAME
SSL enabled, port 443

Note the differences in the server settings!

Backup of contact and calendar data

I found this article very helpful for setting up a backup solution for the contact and calendar data.

Check Also

Python module for MCP23S17 for use with the Raspberry Pi

Some time ago I revised the hardware design of the ControlBlock and added test points …

195 comments

  1. This was a huge help! Thank you so much for sharing this. While I am here I want to write another big thank you for all of your work with Retropie. Thank you and thank you!!

  2. Attempted to install this multiple times both with apache and nginx. script no longer is valid. 5-4-2016

  3. Hello, very good script. I just had install my Owncloud Pi several times with it. But now I had a Pi 2 and would like to install owncloud there.
    Works your script with the owncloud version 8.2.1?

  4. Cool script indeed 🙂 Unfortunately, the update function fails on latest owncloud versions which require an .htaccess file to be copied. Unfortunately, the current scripts’ “cp -r owncloud/* /var/www/owncloud/” is missing dot files. Perhaps you want to fix this…

  5. MikeDPitt420

    Thanks very much for this script 😀 I set it up a while back and am running version 6.0 using nginx. Everything has been working great, including folder syncing with android and windows, although I had to make some changes for nginx and webdav to work. If I use the script to upgrade to the newest version, is there a way to keep my nginx settings and insure webdav will continue to work as well? What would be the easiest way to perform this upgrade without “breaking” my current setup? Also, in the newer version is the file size limit larger ? Or is this a dependency of the pi?

  6. SithLordRick

    First off a HUGE thank you as this made installing OC much easier on the Pi 2 than what I was dealing with beforehand. Problem though is how can you logon to the console? I don’t recall setting a Admin password I will say I was working on this late last night so maybe I did miss it but I’m pretty sure there is a admin account for Owncloud..

  7. There are some problem with the scripts.After instaling NGINIX server and owncloud the result is that i can see only empty screen .It’s look like there is misconfiguration in php

  8. Thx.
    I used your script to set up a Pi as fall-back solution for my owncloud on a cubietruck. It works very well.
    Does anyone have experience with using this script on a cubieboard or cubietruck? I guess since it is ‘just’ (impressive work!) a shell script the chances are high that it works on any arm board?

  9. Just wanted to thank PetRockBlog for this super easy way of getting Owncloud onto my Raspberry PI. I now have my own cloud server running the latest version of Owncloud 7.0.2 at time of writing.

    Thanks again PetRockBlog all your hard work to make installing Owncloud nice and easy for everyone is really much appreciated.

  10. Daniel Andersen

    Hey! The install went great but i can’t access locally or via my ip. I have opend port 80 for raspberry’n. I installed with NGiNX. Mayby it isnt running? I have restarted a couple of times..

    • Daniel Andersen

      Ok, i found out that nginx isnt running, this is the error:
      sudo /etc/init.d/nginx start

      Starting nginx: nginx: [emerg] SSL_CTX_use_certificate_chain_file(“/etc/nginx/cert.pem”) failed (SSL: error:02001002:system library:fopen:No such file or directory error:20074002:BIO routines:FILE_CTRL:system lib error:140DC002:SSL routines:SSL_CTX_use_certificate_chain_file:system lib)

      nginx: configuration file /etc/nginx/nginx.conf test failed

  11. Love your work. Thought I might try the same thing for Arch, to test performance. If it works out I’m happy to keep this in your Git repo to keep it simple for everyone. But you know linux well, I don’t, do you think Arch would probably show little difference?

  12. Hi,

    Just had a go at setting this up. Thanks for the script! A few issues. In the admin page it stated that my files weren’t secure and that people on the internet could see them. I got round this by creating the .htaccess file (sudo touch) in /var/www/owncloud.

    The error message has gone away but not really sure if this is the best way! Secondly an error about WEBDAV syncing not working. I’m guessing this is because my server name and certificates are set as my dynamic DNS address and not the local IP.

    I can access fine locally, but when trying to access using my dynamic dns it just doesn’t work. Any ideas? The port forward is setup and online services report the port 8080 is open.
    I go to https://mydynamicdns:8080/owncloud (8080 translates to port 443 of my raspberry pi ip address. Netstat -n on the pi shows 0.0.0.0:443 listening.

  13. I’d like to know if some of the options available on the script works when I already have a working Nginx installation (I’ve got a WordPress blog hosted on my RPi, for example).

    Does the script overwrite that one and maybe makes the current sites and services unreacheable?

    Regards!

  14. Thanks for the script – it makes my life easier. I had dealed with a lot of advices on the net but now I get it up and running within one hour.
    Unfortunately, I came across an error (but I quickly found a solution) and would like to share my findings.
    The script puts the ownCloud installation to /var/www/owncloud – that’s fine.
    But together with the nginx root folder entry /var/www leads this to an error message in the administrator page of owncloud:
    ——– German ——–
    Ihr Web-Server ist noch nicht für eine Datei-Synchronisation konfiguriert, weil die WebDAV-Schnittstelle vermutlich defekt ist. Bitte prüfen Sie die Installationsanleitungen.
    ——– English ———
    Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken. Please double check the installation guides.
    —————————-
    The solution which works for me is to change the nginx config file at /etc/nginx/sites-available/default and change the line
    root /var/www/; to
    root /var/www/owncloud;

    I am sure there are other solutions possible.

    • Detlef,
      I confirm the problem reported by you.
      Unfortunately the solution doesn’t work for me. I restarted the server , I tried twice. I re-set
      root /var/www/;
      and it works again.
      Cheers

    • Confirmed. Just a restart of the server helped it.
      sudo service nginx restart

  15. Problems after update.
    Hi, first of all, thank you for your work and this blog, I leveraged successfully on it since long time. Unfortunately I have a problem now: I just updated the raspberry installation using your script, as in the past, when the procedure went well at least a couple of times, but not this one. As background, before OwnCloud i did an update of the overall Raspian, without any difficulty; and I’m using NGiNX. After the update I rebooted, but the server doesn’t answer, either connecting the IP from the browser or directly through the OwnCloud client for OSX.
    I see many options in front of me, from a full re-installation to a more pragmatic installation over another SD card, just to test if this latest build works fine. In the first case I will lose my data, option which I don’t like too much. I regret I updated, I’m using the system to host my calendar etc and fromn all my devices.
    Please, do you have any suggestion on configuration files or any other thing I may be able to check to re-establish the full funtionality?
    Thanks

    • Update: I recreated a new installation on a new SD and it works fine. On the old one the problem is not solved. Any suggestion on what to copy – how to recover my data for the new instalation will be appreciated.

  16. Standard MySQL support would be great! Performance with SQLite and more than one ownCloud user or with a few hundred files becomes really bad. Even ownCloud advises not to use SQLite (http://doc.owncloud.org/server/5.0/admin_manual/configuration/configuration_database.html) I even think that SQLite’s suitability for single user use is a lie.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

We use Cookies and similar technology to collect and analyse information about the users of this website. We use this information to enhance the content, advertising and other services available on the site. Please click ‘Accept cookies’ to consent to the use of this technology by petrockblock. You can manage your preferences at any time by visiting our Cookies Policy page.