In this project, we’re going to make a Raspberry Pi Owncloud server this can act as your very own personal cloud storage.

As the protection of your privacy becomes harder and harder, you may be thinking of moving your files to a private cloud storage. If this is the case, then this tutorial is perfect for you.
It is important to remember that since your data will be stored on your local network, you will end up with using more bandwidth if uploading and downloading files from outside your network.
This tutorial will take you through everything you need to know to get Owncloud setup and accessible.
If you’re 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
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.
Video
If you’re a visual person and would like to see our video on how to put this tutorial together, then 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 Raspbian installed. If you haven’t installed Raspbian, then check out our guide on how to install Raspbian via NOOBS (New Out of the Box Software).
There are quite a few ways you’re able to install Owncloud onto your Raspberry Pi. In this particular tutorial, we’re going to be downloading a web server (Nginx) and Owncloud.
Installing NGINX and PHP
The first thing we need to do is install both NGINX and PHP to our Raspberry Pi. We will need both of these pieces of software to run the Owncloud software.
1. Firstly, in either The Pi’s command line or via SSH, we will need to update the Raspberry Pi and its packages, do this by entering:
2. Next, we need to add the www-data
user to the www-data
group.
These instructions have been updated to work with Raspberry Pi OS Bullseye. If you’re on an earlier version, then I highly recommend you upgrade to Raspbian Bullseye before continuing.
You can follow our guide on upgrading from Raspberry Pi OS Buster to Bullseye.
Alternatively, we do have a workaround if you want to stick with an older release of Raspberry Pi OS.
3. Once you are running Raspbian Buster, you can safely continue with this tutorial.
In this step, we will be installing all the packages that we require to run Owncloud. This includes PHP 7.4 and its numerous modules that OwnCloud relies upon.
Run the following command to install everything we need.
When running this command on older versions of Raspberry Pi OS, you might run into a “package not found
” error. You can work around most of these by adding a third-party PHP repository to your operating system.
Setting up NGINX for Owncloud and HTTPS
Our next step is to now set up and configure NGINX for it to work with the Owncloud software. We will also be setting NGINX up so that it can support HTTPS connections as well.
1. Now we need to create an SSL certificate you can do this by running the following command:
Just enter the relevant data for each of the questions it asks you.
2. In addition to the SSL certificate, we also need to generate a custom dhparam file. This file helps ensure that our SSL connections are kept secure. By default, this would use a default one that isn’t nearly as secure.
To generate a 2048 byte long dhparam file, run the following command on your Raspberry Pi. This process will take quite a long time, up to 2 hours.
Adding the dhparam
flag to the command will help speed up the process, but arguably is less secure.
3. Now we need to chmod the three cert files we just generated.
4. Let’s clear the server config file since we will be copying and pasting our own version in it.
5. Now let’s configure the web server configuration so that it runs Owncloud correctly. I use the nano text editor to edit most files.
6. Now simply copy and paste the following code into the file.
7. Now save and exit out of the file by pressing CTRL + X, then Y, followed by ENTER.
8. As we have made changes to NGINX’s configuration we need to restart it’s service by running the following command.
Tweaking PHP for Owncloud
With NGINX now set up, we can now go ahead and prepare PHP to work with our Owncloud installation. As we use php-fpm
, there are a few additional things we need to do.
1. Now that is done, there are a few more configurations we will need to update, first open up the PHP config file by entering.
2. In this file, we want to find and update the following lines. (CTRL + W allows you to search)
Find
Replace With
Find
Replace With
3. Once done, save and then exit by pressing CTRL + X, followed by Y, then ENTER.
4. Our next step is to make some changes to the php-fpm pool configuration. The reason for this is that php-fpm can’t access environment variables.
Run the following command to begin modifying the configuration file.
5. Within this file, find the following block of code and replace it with what we have below.
You can use CTRL + W to find this block of code faster. Typically its located near the bottom of the file.
Find
Replace With
6. With these changes made, go ahead and save the file by pressing CTRL + X, followed by Y, then ENTER.
Adding Swap Memory
Our next step is to add some swap memory to our system.
Adding swap memory allows the Raspberry Pi to work further beyond its memory by making use of space on the storage device. While a lot slower then RAM it is better then the program crashing
1. To increase the amount of swap memory, we need to modify a file called dphys-swapfile
.
To modify this file, make use of the following command:
2. Within this file, find the following line and change it to what we have below.
Find
Replace With
3. Once done, save and then quit by pressing CTRL + X, followed by Y, then ENTER.
4. For our changes to take effect, we will need to now restart the Raspberry Pi by running the command below.
Setting up a MySQL Database & User for Owncloud
Before beginning this section, you must have already set up a MySQL server on your Raspberry Pi.
1. To be able to create our database, we will need to make use of the MySQL command-line interface.
We can load up the tool by running the following command.
2. Once logged in, you can begin interacting with your MySQL server.
The database we will be creating is called ownclouddb
. We can create this database by running the following command.
3. With the database created, let’s now create a user that can interact with it.
We can create a user called ownclouduser
by running the command below. Make sure that you replace [PASSWORD]
with a secure password and make a note of it for later.
4. Our next step is to give access permissions to our new user.
We can grant these privileges by running the following command.
5. The final task is to flush the privileges. If we don’t do this, then our changes won’t be utilized by the server.
To flush the privileges, all we need to do is run the following command.
Once the privilege table has been flushed, we can proceed to install and set up the Owncloud software.
Downloading & Extracting Owncloud
Now in this section, we will be installing the actual Owncloud software on to our Raspberry Pi. Installing Owncloud requires a couple of straightforward steps.
1. Once the Pi has restarted, you will need to install Owncloud onto the Raspberry Pi.
Let us change to the directory where we will be running the script from.
2. Now that we are in the right directory we can now download the latest version of Owncloud.
To do this we will make use of wget by running the command below.
3. Now extract the archive we downloaded by using the tar command.
4. With everything extracted we need to make sure that the www-data
owns the files.
We can recursively modify the permissions of the file by using the chown command.
5. Now we need to open up the .user.ini
file to enforce some of the changes we made earlier in the tutorial
6. In here update the following values, so they are 2000M:
7. Now that is done, we should be able to connect to Owncloud at your PI’s IP address.
Before you set up the admin account, you might want to mount an external drive, so you have lots of disk space for your Raspberry Pi Owncloud server. Just follow the instructions in the next section.
Mounting & Setting up a Drive
Setting up an external drive while should be relatively straightforward but sometimes things don’t work as correctly as they should.
These instructions are for mounting and allowing Owncloud to store files onto an external hard drive.
1. Firstly if you have an NTFS drive we will need to install an NTFS package by entering the following:
2. Now let’s make a directory we can mount.
3. Now we need to get the GID, UID, and the UUID as we will need to use these soon. Enter the following command for the GID:
4. Now for the UID enter the following command:
5. Also if we get the UUID of the hard drive, the Pi will remember this drive even if you plug it into a different USB port.

Copy the light blue letters and numbers of the last entry (Should have something like -> ../../sda1 at the end of it).
6. Now let’s add your drive into the fstab file so that it will boot with the correct permissions.
7. Now add the following line to the bottom of the file, updating UID, GUID and the UUID with the values we got above. (The following should all be on a single line)
8. Reboot the Raspberry Pi, and the drives should automatically be mounted. If they are mounted, we’re all good to go.
Note: If you get an error stating the Pi is in emergency mode at boot up then this likely means a problem with the fstab entry. Just edit the fstab file (sudo nano /etc/fstab
) and remove the added line or look for a mistake and fix it.
Setting up Owncloud
I will briefly go through the basics of setting up Owncloud Raspberry Pi here. 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.
1. In your favorite web browser, you need to go to your Raspberry Pi’s IP address.
If you don’t know your Pi’s local IP, you can run the hostname command.
2. Once you go to the IP you’re like to get a certificate error, add this to your exception list as it will be safe to proceed.
On Chrome, you click the Show advanced
button (1.).
Then click “Proceed to [YOURPISIPADDRESS] (unsafe)
” (2.).

3. When you first open up Owncloud, you will need to do some initial setup steps.
The first thing you need to do is specify a username
and password
for your Owncloud admin account. (1.)
Next, we need to bring up the storage and database settings. You can do this by clicking the “Storage & database” dropdown (2.).
If you are using a different data folder, you can specify it now by using the Data folder
textbox (3.)
We then need to bring up the MySQL database options. You can find these by clicking the MySQL/MariaDB toggle (4.).
Next, we need to fill out three bits of information, the database user, the password for that user, and the database name.
- First, you need to specify the “Database user” (A.). If you are following this guide, this should be
ownclouduser
. - The second option you will need to specify the password you set for the above user. (B.)
- Finally, we need to set the database name. (C.) If you have used the ones from this tutorial, you should set this to
ownclouddb
.
Once you have finished with all the settings, click the Finish setup
button (4.).

If you ever need to update and you find the internal updater is not working, this likely means you will need to do it manually.
You can find a detailed process on how to update over at Owncloud’s update manual page.
The next two sections will show you how to improve your Owncloud software even further.
Setting up Memory Caching for Owncloud
In this section, we will be showing you how to configure Owncloud to make use of APCu and Redis. APCu is used as an object memory cache, and Redis is used to deal with transactional file locking.
Using both of these will help improve the performance of Owncloud on your Raspberry Pi.
1. To be able to enable these, we ill need to make a change to the Owncloud configuration file.
Begin editing this file by running the following command.
2. Within this file, find the following line and add the block of text below it.
Find
Add Below
3. Once done, save the file by pressing CTRL + X, then Y, followed by ENTER.
Using System Cron with Owncloud
The Owncloud team recommends that you should set it up so that the operating system runs the scripts cron jobs instead of Ajax.
1. To be able to set up a cron job for Owncloud, we will need to make use of the www-data
user’s crontab.
Begin modifying the user’s cron by running the following command.
If you are asked what editor you should use to modify the crontab, we highly recommend that you use nano
.
2. Add the following line to the bottom of this file.
This line will run Owncloud’s cron job every minute.
3. Once done, save the file by pressing CTRL + X, followed by Y, then ENTER.
You should now have Owncloud set up correctly on your Raspberry Pi.
Port Forwarding & External Access
If you want to have access to your cloud drive outside your local network, then you will need to setup port forwarding and make a few changes to our config files.
You can get your external IP address at what is my IP.
If you have a dynamic IP you may want to set up a dynamic DNS and use that as your address. You can find information on this in my guide to port forwarding.
To do this open up the Owncloud config file by using the following command.
In here add a new item to the trusted domains array (This will be your external IP address). Your new entry should look something like this (x are just placeholders).
Finally update the URL of the “overwrite.cli.url
” line to your IP Address. It should look something like this.
Below is an example of the completed config.txt
file.

Be sure to check out my guide on port forwarding and use the following port 443 for internal, and I recommended a random port for the external port. Make sure when setting up the external port that it isn’t already reserved for a specific program.
When connecting to the Owncloud server externally, you will need to make sure you use https otherwise you will get an invalid request in your browser.
Setting up port forwarding is super easy to do and allows you to have access to your personal cloud on the go. Also after you have done this, you can still connect via your local IP as well.
I hope this tutorial has helped you make your very own Raspberry Pi OwnCloud. If you have any troubles, want to leave feedback or if I have missed anything feel free to drop us a comment below.
Source: https://pimylifeup.com/raspberry-pi-owncloud/?fbclid=IwAR2lcbSZGuM9TmSrxOkZ_M1gyJehPoxSuBeLkmIq3SzSf0SogqJ10Vm4EPE