How to Install OwnCloud 9 on Raspberry Pi

Our goal in this long journey of installing ownCloud 9 on the Raspberry pi is not just installing ownCloud but also mounting an external drive for lager capacity of data storage and to be able to access it from anywhere in the world.

This tutorial assumes that you have a fully functional Raspberry pi-2 or 3 with Raspbian installed and a 8 GB Micro SD card Minimum!. If you haven’t installed Raspbian then check out my guide on how to install Raspbian via NOOBS.

There are many ways to install ownCloud onto a Raspberry Pi. This particular tutorial I’ll be downloading and installing the following software / packages we will be using to setup ownCloud 9:

• ownCloud 9.0.2
• Nginx
• OpenSSL
• php 5

If you don’t have a Raspberry PI I would personally recommend buying the Raspberry pi-3 kit with a 32 GB Micro SD card so that you don’t have to mount an external drive. unless you want to store more than 32GB of data.

Video Tutorial:

Setting up Raspberry Pi for Owncloud Server

1. Turn on the Raspberry Pi. From the terminal or SSH enter the following command:

sudo raspi-config

The following changes needs to be made in the Raspberry Pi configuration

a. Expand the root filesystem to have enough space for the cloud
Select “Expand Filesystem

b. Change user password
For Security when accessing form the WAN

c. Change locale to en_US.UTF8
Select “Internationalisation Options

d. Memory split, allocate 16M to video graphics
Select “Advanced Options” –> “Memory Split

e. Overclock to Modest or Medium
Select “Overclock

2. Update the Raspberry Pi and its packages:

sudo apt-get update
sudo apt-get upgrade

3. Add the www-data user to the www-data group:

sudo usermod -a -G www-data www-data

4. Install the required packages:

sudo apt-get install nginx openssl ssl-cert php5-cli php5-sqlite php5-gd php5-common php5-cgi sqlite3 php-pear php-apc curl libapr1 libtool curl libcurl4-openssl-dev php-xml-parser php5 php5-dev php5-curl php5-gd php5-fpm memcached php5-memcache varnish

5. Create an SSL certificates for 2 years:

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

6. chmod the two cert files we just generated:

sudo chmod 600 /etc/nginx/cert.pem
sudo chmod 600 /etc/nginx/cert.key

7. let’s move to backup nginx default cofiguration file:

sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default_old

8. create a new nginx default cofiguration file:

sudo nano /etc/nginx/sites-available/default

9. Now  copy and paste the code underneath into the file. Replace “IPaddress” next to “server_name” with your Raspberry Pi’s IP (There is 2 of them).

upstream php-handler {
    #server unix:/var/run/php5-fpm.sock;
server {
    listen 80;
    server_name IPaddress;
    return 301 https://$server_name$request_uri; # enforce https
server {
    listen 443 ssl;
    server_name IPaddress;
    ssl_certificate /etc/nginx/cert.pem;
    ssl_certificate_key /etc/nginx/cert.key;
    # Path to the root of your installation
    root /var/www/owncloud;
    client_max_body_size 1000M; # 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;
    index index.php;
    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 ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
        deny all;
    location / {
        # The following 2 rules are only needed with webfinger
        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(?:$|/) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        fastcgi_pass php-handler;
    # Optional: set long EXPIRES header on static assets
    location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
         expires 30d;
         # Optional: Don't log access to assets
         access_log off;

10. Now save and exit by pressing Ctrl plus X, Y for yes and enter key on your keyboard.

11. Configure max upload limit in php:

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

Use Ctrl+w to search for the lines below and update:

upload_max_filesize = 2000M
post_max_size = 2000M

12. Update PHP listen line:

sudo nano /etc/php5/fpm/pool.d/www.conf

Change the following line from:

listen = /var/run/php5-fpm.sock
listen =

13. Update the conf_swapsize line:

sudo nano /etc/dphys-swapfile

Change the following line from:


14. Restart the pi:

sudo reboot

Installing ownCloud 9:

15. Once the Pi has fully restarted we are ready to install ownCloud version 9.0.2 by entering the following commands:

sudo mkdir -p /var/www/owncloud
sudo wget
sudo tar xvf owncloud-9.0.2.tar.bz2
sudo mv owncloud/ /var/www/
sudo chown -R www-data:www-data /var/www
rm -rf owncloud owncloud-9.0.2.tar.bz2

16. If you are NOT mounting an external hard drive to the raspberry pi then you are ready to log into your ownCloud Server by entering the RPI IP address into the address bar.

If  you’re mounting an external hard drive so you’d have lots of disk space for your Raspberry Pi ownCloud server, you would need to mount the hard drive before you log into your ownCloud Server. Simply follow the instructions below.

Mounting and Setting up a drive

These instructions are for mounting an NTFS formatted hard drive and allowing ownCloud to store files onto it.

1. Having an NTFS drive we will need to install a NFTS package by entering the following:

sudo apt-get install ntfs-3g

2. Make a directory we can mount to:

sudo mkdir /media/ownclouddrive

3. Now we need to get the gid, uid and the uuid as we will need to use them so the pi will remember it even if we plug it into a different USB port. Enter the following command for the gid:

id -g www-data

4. Now to get the uid enter the following command:

id -u www-data

5. Also we meed to get the UUID of the attached external hard drive so the Pi can remember this drive even if you plug it into a different USB port.

ls -l /dev/disk/by-uuid

6. Then copy the light blue letters and numbers of the sda1 entry usually located on the bottom. Should look something like (numbers&letters -> ../../sda1). See picture below:


7. Now add your drive into the fstab file so it’ll boot with the proper permissions.

sudo nano /etc/fstab

8. Add the following line to the bottom of the file, updating uid, guid and the UUID with the values we got above. (It should all be a single line)

UUID=F6941E59941E1D25 /media/ownclouddrive auto nofail,uid=33,gid=33,umask=0027,dmask=0027,noatime 0 0


9. Reboot the Raspberry Pi:

sudo reboot

10. Now the drives should automatically be mounted. If mounted we’re all good to go. To check it enter:

sudo ls /media/ownclouddrive

Personal Cloud Storage

If there are files inside the drive you should be able to see them here. If it’s an empty drive you might not see anything so don’t be surprise if nothing shows up.

If you want to be absolutely positive that the drive is properly mounted, unplug the drive from the RPI plug it onto a PC since the drive is formatted “NTFS” it should be easily detected by the PC, open it, create an txt file name it test, then eject it and plug it back to the RPI and run the following command:

sudo ls /media/ownclouddrive

The txt file you created should be there.

Basic First Access Setup

1. Open your browser and enter the IP address provided, in my case is you’ll be directed to your ownCloud storage server.

2. Because we installed SSL for more security you might get a certificate error, simply add the certificate to your exception list to proceed.

3. You should be presented with a simple setup screen, Here enter a username and password to create an admin account.

4. Click on Storage & database dropdown and enter your external hard drive: /media/ownclouddrive (Skip this if you didn’t setup an external drive).

5. Click Finish setup.


Done! !! all is left is to configure your devices to access your ownCloud storage.

Port Forward for External Access

Log into your router and get the WAN IP address:


Or Google what is my IP address?


Now we need to add the WAN IP to your trusted IP list and not to be overwritten by ownCloud. To do this open the Owncloud config file, enter:

sudo nano /var/www/owncloud/config/config.php

Here add the WAN IP (External IP address) you just got from the router or Google to the trusted domains array. Your new entry should look something like this:

1 => '',

X are just placeholders. Replace the X’s with the WAN IP Address.

Now update the URL of the overwrite.cli.url line with your WAN IP Address. It should look something like this:

'overwrite.cli.url' => '',

Here is an example of the completed config.txt file.


Once done save and restart the nginx service:

sudo service nginx restart

Now log into your router and navigate to the port forward section.


Now port forward SSL port 443 to the Raspberry pi internal IP (LAN IP)  address and save settings.


Now your RPI ownCloud is ready to be accessed externally (WAN) and from your devices just download the ownCloud App and enter: “https:// WAN IP Address” on the address bar or devices. below is an example:


Latest Comments

  1. Martin1
    • Miguel
      • Joseph Namulauulu
        • Miguel
          • Joseph Namulauulu
  2. Ruben
  3. Iker
  4. basheer
    • Miguel
      • Gavin Rook
        • Miguel
          • Gavin Rook

Leave a Reply