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:

Then you can download the latest PiCloud setup script with

The script is executed with

The initial screen should then look like this:

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.

  • decon

    I installed the the script but I can’t log in. When I try I just get a loading icon in my browser and then I get kicked back to the logon screen. It doesn’t matter if the password is right or wrong (I don’t even get an error message :/). I can’t get anywhere from the logon screen.

  • http://twitter.com/joffaMac joffa

    I followed the instructions and used the script and it all worked fine – I can log in locally so will now work on storage. However, I don’t know where else to ask so start here – in regards to the my.servername.com part of the script, I’m at a loss. I want to use my domain name with gandi.net but haven’t a clue what exactly I do or what in fact I need to ask. I currently use gandi.net for personal email with gmail – I followed the gandi instructions to achieve it but don’t understand it. In order to access my owncloud from anywhere on the www, how do I set it up with gandi.net? Do I have to use something like dysdns.com? Simple step by step instructions for a nob would be appreciated. Thanks in advance.

    • http://www.petrockblock.com/ petRockBlog

      I am using dyndns.org and configured my router accordingly. my.servername.com is then replaced by the dyndns URL. Unfortunately, I do not have the time to write a step-by-step guide in these days, but maybe someone else can post a link to such an article here!?

  • Jasper

    I tried installing this nice script, but I fail with the cloning from github. I do not have experience with git, but it gives me the following error:

    “Cloning into ‘OwnCloudPie’…
    fatal: remote error: repository not found”

    I have opened port 9418 on my router for github, but it seems I need some other setting… I use the latest Wheezy (2-9-2013).

    • Jasper

      Nevermind. Seems like I entered something wrong in the line myself. Copy pasting through telent did the trick

      • http://www.petrockblock.com/ petRockBlog

        Glad to hear :-)

  • Mats Sandvoll

    Hi,
    What is the best way to uninstall the OC server? I want to do a clean install with apache.

    Thanks!

    • http://www.petrockblock.com/ petRockBlog

      You can uninstall nginx together with the configuration files with the command sudo apt-get purge nginx.
      The Owncloud files are installed in the directory /var/www/owncloud by the OwncloudPie Script. If you want to remove them you could do it with sudo rm -rf /var/www/owncloud

  • KissShot

    HI,
    Is there any method to just change server’s IP that I typed in the first section of Installation?

    Thank you for make&sharing this amazing script!!

    • http://www.petrockblock.com/ petRockBlog

      You can run the script again and choose the first menu entry only (the one that allows you to set the server URL). That will modify the NGiNX server settings as well. Remember that you need to restart the service (or the whole system if you like) before these changes take effect.

      • KissShot

        how can i modify url without selecting new installation?

      • KissShot

        i’ve solved problem by modifying “/etc/nginx/sites-available/default files”
        by manual.

        thankyou again for this script

      • http://www.petrockblock.com/ petRockBlog

        Glad to hear that!

  • Bernd

    Hi,
    thanks a lot for this script. I had it only used for updating my existing owncloud-installation because I´m not very firm with linux. It worked fine, thanks.
    Bernd

  • Magnus

    Does this script work with ubuntu server 12.10 with owncloud 5.0? I want to update to 5.0.3 :)

    • http://www.petrockblock.com/ petRockBlog

      Personally, I do not have any experience with this script when used with a distribution other than Raspbian. Maybe someone else has tried it?

  • HughJasole

    How do I set the OwnCloud data directory to an external 3TB drive (/dev/sda1 mounted to /mnt/usb1)? I installed OwnCloud using the manual method and always received permission errors when trying to use a different data folder than the default.

  • HughJasole

    Does anyone know how I can change the default data directory to an external USB drive (/dev/sda1/ mounted to /mnt/usb1)?

    • pwl

      isn’t it enough to edit config/cpnfig.php ?
      i’d guess to change ‘datadirectory’ => ‘/mnt/usb1′,

    • http://twitter.com/jijijaco jijijaco

      You should mount the external drive by adding it in fstab.

      Then in my case I just make a symbolic link from /var/www to /mnt/MYMOUNTPOINT/www/
      (the command is something like ln -s /FROM /TO)
      You can do it from/to any folder.

      This is an easy workaround that works really well.

  • Mats Sandvoll

    Have anyone tried php accelerator with this script? I have installed apc, but I don’t know the best way to configure it.

    Thanks!

  • Adam

    hello there run the script and when i try to connect I get error 403 forbidden?

    using nginx

  • clive

    Just tried this and get a 403 forbidden page using NGINX.

    Can you fix it please.

    Many thanks