User Tools

Site Tools


How-to setup an ownCloud server

ownCloud is a cloud solution for files, contacts and calendars hosted on your own hardware.

The tutorials from Jan Karres and meinnoteblog helped me a lot with my installation (both in German).

This tutorial is using the following components:

Basic Raspberry PI preparation

Step 1: Wheezy Raspbian

This tutorial ist based on the Wheezy Raspbian operating system. The installation steps are described here.

Step 2: Disable SWAP

My Raspberry PI should run 24/7 so I disabled the SWAP-file in order to reduce the write activities to the SD-card.

Disable SWAP

Step 3: Memory Split

Reduce the memory size to 16MB for the GPU.

sudo raspi-config
  • Select “8 Advanced Options”.
  • Select “A3 Memory Split”.
  • Set the value to 16.

Step 4: Overclock

I decided to overclock the Raspberry PI to 900Mhz. This is 200Mhz more than the default.

sudo raspi-config
  • Select “7 Overclock”.
  • Select “Medium 900MHz ARM, 250MHz core, 450MHz SDRAM, 2 overvolt”.

See more details here.

Install Prerequisites

Step 5: Install nginx, PHP and MySQL

sudo apt-get install nginx php5 php5-fpm php-pear php5-common php5-mcrypt php5-mysql php5-cli php5-gd php-apc mysql-server

Step 6: Limit resources for nginx

Change the nginx configuration file in order to limit the usage of system resources:

sudo nano /etc/nginx/nginx.conf

Change the values for worker_processes to 1 and worker_connections to 128:

user www-data;
worker_processes 1;
pid /var/run/;
events {
        worker_connections 128;
        # multi_accept on;

Restart nginx:

sudo /etc/init.d/nginx restart

Step 7: Configure PHP

Create temporary folder for file Uploads with PHP:

sudo mkdir -p /srv/http/owncloud/data
sudo chown www-data:www-data /srv/http/owncloud/data

Change the PHP configuration file:

sudo nano /etc/php5/fpm/php.ini

Change the values for upload_max_filesize and post_max_size to 1024M:

upload_max_filesize = 1024M
post_max_size = 1024M

Add these lines at the end of the file:

upload_tmp_dir = /srv/http/owncloud/data
apc.enabled = 1
apc.include_once_override = 0
apc.shm_size = 256M

Step 8: Create SSL certificate

sudo openssl req $@ -new -x509 -days 365 -nodes -out /etc/nginx/cert.pem -keyout /etc/nginx/cert.key
sudo chmod 600 /etc/nginx/cert.pem
sudo chmod 600 /etc/nginx/cert.key

Step 8: Configure nginx

Replace SERVERNAME with your own servername or dyndns address:

# You may add here your
# server {
#	...
# }
# statements for each of your virtual hosts to this file
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
server {
   listen 80;
    server_name SERVERNAME;
    rewrite ^ https://$server_name$request_uri? permanent; # enforce https
server {
    listen 443 ssl;
    server_name SERVERNAME;
    ssl_certificate /etc/nginx/cert.pem;
    ssl_certificate_key /etc/nginx/cert.key;
    root /var/www/owncloud;
    index index.php;
    client_max_body_size 10G; # set max upload size
    fastcgi_buffers 64 4K;
    rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
    rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
    rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
    error_page 403 = /core/templates/403.php;
    error_page 404 = /core/templates/404.php;
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
        deny all;
    location / {
        rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
        rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
        rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
        rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
        rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
        try_files $uri $uri/ index.php;
    location ~ ^(.+?\.php)(/.*)?$ {
        try_files $1 = 404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$1;
        fastcgi_param PATH_INFO $2;
        fastcgi_param HTTPS on;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
        expires 30d;
        # Optional: Don't log access to assets
        access_log off;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    location ~ /\.ht {
        deny all;

Restart nginx and PHP-FPM:

sudo /etc/init.d/nginx restart
sudo /etc/init.d/php5-fpm restart

Step 9: Configure MySQL

Replace PASSWORT with your own Password for the user owncloud:

mysql -u root -p 
create database owncloud; 
create user 'owncloud'@'localhost' identified by 'PASSWORT';
grant all privileges on owncloud.* to 'owncloud'@'localhost';

Install ownCloud

Optional replace the download URL with the link to the current version of ownCloud (in this case 6.0.1):

Step 10: Download & extract ownCloud

sudo mkdir /var/www
cd /var/www
sudo wget
sudo tar xvf owncloud-6.0.1.tar.bz2
sudo rm owncloud-6.0.1.tar.bz2
sudo chown -R www-data:www-data /var/www

Step 11: Create cronjob

By Default ownCloud is running a script each time using the web access. This makes the Raspberry PI pretty slow. An alternative is to run every 5 minutes this script as a cronjob:

sudo crontab -u www-data -e

Add this line to end of the file:

*/5 * * * * php -f /var/www/owncloud/cron.php

Step 12: Configure ownCloud

On the first time opening the ownCloud website with a browser it is necessary to make some basic setup:

  • admin user (e.g. admin)
  • admin password
  • path to file storage (e.g. /var/www/owncloud/data)
  • MySQL user (step 9)
  • MySQL Password (step 9)
  • MySQL database (step 9)
  • MySQL server (e.g. localhost)

Finally it is necessary to change the cron type from AJAX to Cron in the Admin settings.

Use samba share for data

By default the files of the users are stored in the folder /var/www/owncloud/data on the SD-card. I expect to uploud many files to my ownCloud, so it makes sense to store the files on my NAS.

Step 13: Create cfis-share

Create a samba/cfis share on your NAS and assign read/write rights to a NAS user (I created the user owncloud for it).

Step 14: Create cfis-share be continued..

setupowncloud.txt · Last modified: 31.01.2014 19:57 by derk