In this project, we are going to set up an ownCloud server on the Raspberry Pi. This server can act as your very own personal cloud storage.

As protecting your privacy becomes harder and harder, you may be considering moving your files to a private self-hosted cloud storage. If this is the case, then this tutorial is perfect for you.
The ownCloud web interface is very similar to the many cloud storage providers that are available, such as Dropbox, Google Drive, and more. This similarity will make changing over to the self-hosted software much easier.
It is important to remember that since your data will be stored on your home network, you will end up with using more bandwidth if you upload and download files from outside your network.
This tutorial will take you through everything you need to know to get ownCloud setup and accessible.
If you are curious and want to learn more about the ownCloud software, be sure to check out the ownCloud website.
Equipment
I made use of the following equipment for this personal cloud storage setup.
Recommended
- Raspberry Pi ( Amazon )
- Micro SD Card ( Amazon )
- Ethernet Cable ( Amazon ) or Wi-Fi ( Amazon )
- External Hard Drive ( Amazon ) or USB Drive ( Amazon )
Optional
Note: It is highly likely that the USB ports on the Raspberry Pi will be unable to power an external hard drive so you may need to invest in a powered USB hub.
We last tested this tutorial on the Raspberry Pi 5 running Raspberry Pi OS Bookworm. We highly recommend that you update the to the latest operating system for the best experience.
Video
If you are a visual person and would like to see our video on how to put this tutorial together, check out the video below.
It will take you through everything you need to know get your Raspberry Pi ownCloud server up and running.
Setting up The Raspberry Pi ownCloud Server
Firstly, you will need to have a Raspberry Pi with an OS installed. If you haven’t installed Raspberry Pi OS, then check out our guide on installing Raspberry Pi OS. We recommend using the latest version for the best performance and reliability.
There are quite a few ways you can install ownCloud onto your Raspberry Pi. In this tutorial, we will be using Docker to set up ownCloud.
In our previous version of this tutorial, we used Nginx, but this method is deprecated, and we now recommend using Docker, especially since ownCloud still relies on PHP7.4.
Installing Docker
The first thing we need to do is install Docker on our Raspberry Pi. We will need this software to run the ownCloud software.
1. Firstly, in the terminal or via SSH, we will need to update the Raspberry Pi and its packages. Do this by entering the following two commands.
sudo apt update
sudo apt upgrade -y
2. You will need to ensure that you have Docker on your Raspberry Pi before proceeding to the next few steps. If you already have it installed, go to step 3.
If you need to install Docker, run through our tutorial on setting up Docker on the Raspberry Pi. It will take you through all the steps to set up the software correctly.
https://pimylifeup.com/raspberry-pi-docker/
Creating the Required Directories
3. We now need to create the directories for where we will store the compose file and environment variables.
You can do this by running the mkdir command. The “-p
” option will create any missing directories.
sudo mkdir -p /opt/stacks/owncloud
4. Now change into the newly created directory by using the cd command.
cd /opt/stacks/owncloud
Setting up the Docker Compose File
5. Before we proceed, we will need to get the IP address of the Raspberry Pi. You will need to use the IP address in the environment file and to access the ownCloud web interface.
I recommend that you set your Raspberry Pi IP to static to avoid it changing in the future.
To get the IP address of the Raspberry Pi, enter the hostname command with the option “-I
“.
hostname -I
6. It is time to write a compose file for our ownCloud setup. This file is a set of instructions Docker will run through to set up all the relevant services with the specified options. Alongside ownCloud, we will be setting up a MySQL and a Redis server.
Create and edit this file by running the following command. We will be using the nano text editor.
sudo nano compose.yaml
7. In this file, copy and paste the following text. Thankfully, we do not need to make any changes to this file, as any extra configurations will be stored in an environment file.
services:
owncloud:
image: owncloud/server:${OWNCLOUD_VERSION}
container_name: owncloud_server
restart: always
ports:
- ${HTTP_PORT}:8080
depends_on:
- mariadb
- redis
environment:
- OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
- OWNCLOUD_TRUSTED_DOMAINS=${OWNCLOUD_TRUSTED_DOMAINS}
- OWNCLOUD_DB_TYPE=mysql
- OWNCLOUD_DB_NAME=owncloud
- OWNCLOUD_DB_USERNAME=owncloud
- OWNCLOUD_DB_PASSWORD=owncloud
- OWNCLOUD_DB_HOST=mariadb
- OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
- OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
- OWNCLOUD_MYSQL_UTF8MB4=true
- OWNCLOUD_REDIS_ENABLED=true
- OWNCLOUD_REDIS_HOST=redis
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- ${OWNCLOUD_FILES_LOCATION}:/mnt/data
mariadb:
image: mariadb:10.11 # minimum required ownCloud version is 10.9
container_name: owncloud_mariadb
restart: always
environment:
- MYSQL_ROOT_PASSWORD=owncloud
- MYSQL_USER=owncloud
- MYSQL_PASSWORD=owncloud
- MYSQL_DATABASE=owncloud
- MARIADB_AUTO_UPGRADE=1
command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=owncloud"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- ./mysql:/var/lib/mysql
redis:
image: redis:6
container_name: owncloud_redis
restart: always
command: ["--databases", "1"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- ./redis:/data
Once you are done, save and exit by pressing CTRL + X, Y, and then ENTER.
8. It is time to write the environment file. This file will contain all the configurations we wish to set for the ownCloud software. For example, usernames, passwords, ports, and more. Docker automatically reads it and will match and replace the placeholders in the compose file with the relevant data from the environment file.
To create the environment file, enter the following command.
sudo nano .env
9. In this file, you will need to enter the following lines and replace each placeholder with the value you wish to use. We will explain each of these options below.
OWNCLOUD_VERSION=<VERSION>
OWNCLOUD_DOMAIN=<DOMAINORIP>:<HTTPPORT>
OWNCLOUD_TRUSTED_DOMAINS=<DOMAINORIP>
ADMIN_USERNAME=<ADMINUSERNAME>
ADMIN_PASSWORD=<ADMINPASSWORD>
HTTP_PORT=<HTTPPORT>
OWNCLOUD_FILES_LOCATION=<MOUNTPATH>
<VERSION>
This placeholder represents the version of ownCloud you want to run on your Raspberry Pi. I recommend using thelatest
, but you can always specify an older version such as10
.<DOMAINORIP>
Use this option to specify the allowed address for accessing the ownCloud instance. For example, if I want to use it locally, I will use the local IP, such as192.168.0.15
.
If I want to access the software remotely, I can use an external IP address or domain name. You can add multiple domains and IPs by separating each of them with a comma. For example,192.168.0.15,test.pimylifeup.com
. Please note, that multiple IPs and domains only applies to theOWNCLOUD_TRUSTED_DOMAINS
variable.<HTTPPORT>
This is the default port that ownCloud will listen on. I recommend using a port such as8080
or similar to avoid conflicts with other software.<ADMINUSERNAME>
Replace this placeholder with the username you wish to use for your admin account. You will not be able to change this after the first setup.<ADMINPASSWORD>
Like the username, the admin password is only used for the first setup. Afterward, you will need to change the password in the web interface.<MOUNTPATH>
This is the path for storing the data of ownCloud. Using.data
will store it within/opt/stacks/owncloud
directory. You can change this directory to wherever suits you the best.
You could set it to a mounted drive by using something like/mnt/usb1/owncloud
. A mounted drive is a good option as it allows you to gain access to a lot of storage space.
OWNCLOUD_VERSION=latest
OWNCLOUD_DOMAIN=192.168.0.15:8080
OWNCLOUD_TRUSTED_DOMAINS=192.168.0.15
ADMIN_USERNAME=pimylifeup
ADMIN_PASSWORD=pimylifeup
HTTP_PORT=8080
OWNCLOUD_FILES_LOCATION=./data
Once you are done, save and exit the file by pressing CTRL + X, Y, and then ENTER.
Starting the ownCloud Server with Docker
10. To start your ownCloud server, all you need to do is run the following command.
Once initiated, Docker will download all the required software and start up each of the service with the specified options. Using the -d
option will run Docker in the background.
docker compose up -d
First Start of ownCloud on the Raspberry Pi
I will briefly go through the basics of ownCloud running on the Raspberry Pi. If you want more information, I highly recommend checkout out the manuals on their website. You can find them at the ownCloud manual site here.
11. In your favorite web browser, you need to go to your Raspberry Pi’s IP address.
If you don’t know your IP address, you can run the hostname command on the Raspberry Pi.
hostname -I
Below is an example of the address you will need to enter into the browser. Remember to update the IP address with the one you get from using the command above.
http://192.168.0.15:8080
12. You should now be greeted with a login page similar to the one below. Simply enter the username and password that we set in the environment file.

13. You will now see a page with a pop-up on how you can install the apps for desktop, Android, and iOS.

14. Lastly, test that you can upload files to your ownCloud installation by simply dragging and dropping a file into the web interface. It should upload without any issues.

15. You now have ownCloud installed and running on your Raspberry Pi. The next couple of sections cover the basics for remote access, updating software, and backing it up to somewhere secure.
Setting up Remote Access
If you want to access the server remotely, I highly recommend using a service like Cloudflare Tunnels or Tailscale. These services are relatively easy for most people to understand and setup. Alternatively, setting up a reverse proxy like Traefik, or Nginx proxy manger will also work.
Once you have chosen your method of exposing ownCloud to the internet you will simply need to specify the IP address and port of the software. Most of the software above will generate certificate for your domain name.
Updating ownCloud Docker
Using Docker makes updating your ownCloud software super easy, and only involves a few simple steps.
1. Before you update, we recommend that you backup any data in case something goes wrong with the update. Follow our backup section for more information.
2. You will need to first change to the location of your ownCloud compose file. If you followed this tutorial, use the command below.
cd /opt/stacks/owncloud
3. You can simply tell Docker to pull the latest versions of the software specified in the compose file.
docker compose pull
4. Once the latest software has been downloaded, you must issue the compose up command. This command ensures that the software running in docker is updated to the latest versions we downloaded earlier.
docker compose up -d
Backing up ownCloud Docker
Backing up your data is highly important as data drive failure, natural disasters, corruption, or accidental deletion can happen at any time and when you least expect it. Luckily, backing up data is relatively straightforward.
I recommend you can use rclone on the Raspberry Pi or something similar to copy and store the data in another location. You can also automate the following steps using a bash script and setting up cron.
1. You will need to first change into the location of the compose file.
cd /opt/stacks/owncloud
2. First, stop the docker container by running the following command
docker compose stop
3. The next couple of lines require you to have rclone installed, but they will simply sync the contents from the source location to the destination. For example, /opt/stacks/owncloud/data
will sync to /backups/owncloud/data
.
You can also setup rclone to sync to a remote location rather than local. This method is highly recommended for backing up important data.
sudo rclone sync /opt/stacks/owncloud/data /backups/owncloud/data --progress
sudo rclone sync /opt/stacks/owncloud/mysql /backups/owncloud/mysql --progress
4. Once the above two commands are finished, start the docker container by running the following command.
docker compose up -d
As I mentioned earlier, you can add the above commands into a bash script that you can then automate the backup sequence. I highly recommend that you schedule the backup to occur when the server is least likely to be in use.
Conclusion
I hope this tutorial has helped you set up your very own Raspberry Pi ownCloud. You should now be able to upload and store files within your own personal cloud.
If you are interested in other self-hosted projects, I also recommend taking a look at Immich on the Raspberry Pi. It is a great software for storing and viewing photos.
If you have any troubles, want to leave feedback or if I have missed anything feel free to drop us a comment below.
hello why i can’t access nginx links? is this download links or just a information links?
Looks like they changed the structure of their website without redirecting to the new location. I have fixed the links now, it was just a information link.
Hi. This a great tutorial. Very easy to follow and very thorough.
Question is, does the hard drive need to be in a specific format? Ntfs/fat32?
Thanks in advance
hi, I followed all the steps of driving without a hitch or error, I came to the point: basic first setup, step 1: “In your browser enter your Pi’s IP address in my case it is 192.168.1.116 …..” I enter my ip address, but nothing happens. tells me to load error, Firefox can not establish a connection to the server ….. therefore I am now blocked because I will not open the page owncluod could depend on what? thanks for the concern.
I am noob for Linux. After install owncloud, I tried to upgrade itfrom 9.0.4 to 9.1.4 but never success. I tried using wget download newer version and unzip cover the old owncloud files. The main page still show I am in 9.0.4 version. How can I upgrade the owncloud server?
I may need to move my raspberry pi to another location, and the local IP will change. Is possible to change IP after I installed it?
On step 19, identify the proper version in the wget statement. It should be noted that ownCloud should NOT have already been installed, but a clean install.
IP is easy. Simply, make it static. Most often this can be accomplished by reserving/setting it via the router.
I followed this tutorial, the issues i ran into where the NGINX, for some reason it was not installed on my version of Pi, I got NGINX installed but of course there were a few version changes. and there was some issues with the .html file. most of the time it didn’t exist. I have stopped at the PHP editing. I will let you know how much further i get in this and if i finally get it to work
I’m hoping this website is still being maintained.
When i type my Pi IP-Address into my browser (internet explorer) i get no setup screen instead a text file is downloaded and displayed which seems to contain the copyright licence from onecloud, otherwise nothing happens.
here an excerpt from the file:
<?php
/**
* @author Jarn Friedrich Dreyer
* @author Lukas Reschke
* @author Morris Jobke
* @author Robin Appelman
* @author Thomas Müller
* @author Vincent Petry
*
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
The text then goes on, can anyone advise me on what i am doing wrong or have done wrong (code wise maybe?) here?
Thanks
Jamie
Thanks for the Tut,
Everything is working, but i have some doubts:
I’ve created admin user without any external device mounted.
When I create a user, the default folders, photo and documents are stored on RPI SD card, and everything I put on the cloud stays stored there.
I’ve added now an external device, its mounted and visible for all the users as a folder, but i would like that was the “home” for each user, is it possible?
Hi Gus,
Thanks for you tutorial.
Internal access works fine but I want to expand to access from outside. It would appear that Firefox and Chrome have ‘banned’ self generated certificates. Have you considered (or produced) an extension to this so that genuine Letsencrypt certificates can be obtained and used.
Thank you
Thnx a lot Gus! I like your project. Neat and to the point.
Can I use the same SD(32gb) for storage? If so, I already set an account up, how to add it in there? Please if u can answer today!
Hey Gus,
After I enter the IP of Pi in the browser for owncloud login i get a connection refused error.
Thanks for your guide everything works perfect, except when I access mycloud externally the browser says the certificate is invalid crosses out https and says not secure?
Will this work alongside the web server, or do the changes to localisation and whatnot affect the web server?
Nginx is a webserver in of itself.
when i connect from the other network i am getting an error of
this site can’t be reached
http’s server DNS address could not be found.
search google for https 192.168.137.247
ERR_NAME_NOT_RESOLVED
Firstly, thanks for the great tutorial, Gus! Unfortunately, I have some problems…
I did all the steps very carefully checking each command twice at least. I haven’t finished the last ‘port forwarding’ section because I am stuck. I can access my owncloud client in a browser via raspberry’s IP but after successful logging into it I can only see the default files and directories (Documents, Photos and ownCloud manual.pdf). There are no files from my external hard drive which is mounted properly (I can see the files through ‘ls /media/owncloud’). Also the UUID is set properly.
Is there anything I can check to determine what’s wrong? Please help!
I know exactly what you’re speaking of. I ran into the same issue while upgrading from the RPi2 to a 3. The external drive had everything and I did everything with the thinking that if I put in the proper info it should have just displayed everything upon logging in. And, of course, it didn’t. The resolution I thought was necessary was to wipe the drive and start fresh and sync up everything all over again. It’s just about done, though there’s a lot of gateway timeouts and loss of connection requiring reboots. But, like I said, it’s just about done.
[ UPDATE ]
Correction, now it won’t connect. Nearly a half-dozen reboots and neither the sync will connect nor my manual attempts in a browser will connect, all I get is a blank screen.
I suppose I will have to rebuild the entire thing, again, from a fresh image and hard drive format. Then, manually upload the files one at a time or in very small groups.
I don’ want to format my whole 1GB external hard drive. It would take ages to backup all the data to another drive (BTW i don’t have any). How to upload the files manually since I just want to make a cloud from the directory where my hard drive is mounted? Then all the files should just appear in an ownCloud browser client.
The difficulty there is the data is organized in an ordinary directory structure. Whereas, owncloud uses databases. The data would have to be ported to a database structure such as sqlite or whatnot. owncloud won’t read data straight from a directory (to my knowledge, though I could be wrong).
I would recommend purchasing a portable usb drive or thumbdrive large enough to build the database, hold the data and keep the existing one as a backup.
Ok, so how to move all my data from my usb external drive to another to be sure that owncloud can build the database from that and display all my files in a browser client? Should I use a specific file format?
When installing sqlite, according to this tutorial, it creates the database from where my external drive is mounted, but I faced the problem that after some time it crashes with 504 (or maybe 503) error, so maybe the database needs more time to build itself but it fails? When refreshing client after this error, I have an acocunt but files are not displayed.
When building a database, it starts with an empty one and the data is ported in from another source. That is best for syncing using the Owncloud application. Basically, during a sync setup, is the source is selected and then the folder it would like to be synced to is selected and it then runs and builds the database.
The 5xx errors are typically gateway timeouts. I have found this to be typical of large file sizes and not so much the extension of file type. Though, the type of file being synced has a lot to do with file size. For example, pictures. Typically, those are fairly small. I, for one, have thousands of them. They all synced just fine and with no errors. Video files, however, such as ones that are, let’s say, an entire VHS tape of home movies that was converted to avi is gigantic. That will result in timeouts. If it’s converted from avi to, let’s say, mp4 or mkv, the filesize is much smaller but is still a fairly large file. Timeouts will still result. I am experiencing this, right now, actually. The cause behind it is trying to sync large files on an RPi.
To achieve smaller file sizes, breaking videos up into smaller segments(files) may be a good thing to do. This may require editing them, of course. The file type(extension) isn’t much help, but I certainly recommend mkv or mp4 over avi and similar formats because extensions do make a difference in the end filesize.
And, I have to restart the nginx server a lot. I augment those restarts with both warm and cold reboots, which helps a little. But, it’s a long process with the larger files. The only solution in the bigger picture is building owncloud using a regular PC, laptop, etc. rather than an RPi, because an RPi uses a core that is used in mobile and similar devices.
Hey All, I hope I can get an answer out you guys! I’ve followed every step and seem to have had no problems in doing so, except for the fact that I can’t reach owncloud in my browser.. Any Idea what could be the cause of this? Do I use my internal or external IP in the nginx file?
Many thanks in advance!
The error I get is that the page couldn’t be loaded / Can’t connect to destination.
Hi,
The tutorial is great, but I’m having trouble when I try to access my pi when using the browser. It says that it refuses to connect. Any suggestions?
This is incredible slow if you do not enable MySql! Before you do the setup, run this:
sudo apt-get install php5-mysql
sudo apt-get install mysql-server
Then make sure to setup the mysql database in the owncloud config screen.
Hey guys!
So I followed the steps and am currently on the .htaccess section. However, it’s completely empty… (opens to a black screen with nothing in it). What should I do?
Hi!
Thanks for the tutorial! I’m having a terrific time with a very specific error that happens whenever I try to finish setting up the admin account through my web browser. The error is: “Error trying to create admin user: Failed to connect to the database: An exception occurred while executing ‘PRAGMAjournal_mode=WAL’: SQLSTATE[HY000]: General error: 10 disk I/O error”
I know this has something to do with SQLite but I don’t have a clue as to how to fix it and can’t find much info. I have a RPi3 running Raspian and ownCloud 9.1.3. I’ve gone through the whole procedure 3 times and it always ends up at this error. I’ve tried reformatting the external drive I’m using both as FAT and HTFS. The RPi recognizes the drive and I’m able to configure it as storage for ownCloud and when I unmount it the ownCloud db files are on it. I just can’t get past this error to setup the admin account.
Any help would be greatly appreciated!
Hello,
first of all thank you for this tutorial, installed and configured my ownCloud server but now I need to upgrade to version 9.3.
How am I supposed to do this?