Host your own cloud
Want to store and sync your own files for free, with no storage limits? Why not turn a Raspberry Pi or Windows PC into a personal cloud?
Are you continually running out of space on Dropbox, Google Drive or whatever your chosen cloud platform may be? If so, it’s time to take matters into your own hands. Storing files on your own hardware lets you consolidate and synchronise your data without having to worry about storage limitations – and your privacy can also be better protected. Here’s how to set up either a Raspberry Pi or a spare Windows PC as a personal cloud server, using the free ownCloud platform.
Getting started with the Raspberry Pi
You can install and run ownCloud on a regular Raspberry Pi running Raspbian, but getting it working can be a little complicated, as you also need to install and configure web and database services.
To simplify things, therefore, we’ll ditch Raspbian and use the ultra-light DietPi OS distribution instead. This is based on Debian, like the official operating system, but it’s designed to take up as little space as possible (a minimal installation tips the scales at just 400MB) and to streamline the process of installing core apps and services. Thus, when we install ownCloud on DietPi, the web server and database are also automatically installed and set up so that ownCloud can work from the word go.
As DietPi is still a full, multitasking OS, you’re free to install other services on it too. It makes a great starting point for a do-everything device that can live in a cupboard somewhere and perform a broad range of functions on your network – especially if you’re using something as powerful as a Raspberry Pi 4.
Download and install DietPi
To get the DietPi OS image, head to dietpi.com, scroll down to the Download section, click “Raspberry Pi All models”, then click the download icon next to Download Image.
The DietPi image is stored in 7Z format, which means it can’t be unzipped with Windows’ built-in tools. If you’re not already running it, you can install 7-Zip (7-zip.org) to handle files of this type. Once you’ve extracted the image, you’ll need to write it onto your microSD card: there are plenty of tools that can do this, such as the official Raspberry Pi imager, which is a free download from raspberrypi.org/download.
Once you’ve written the image to the card, you’ll be told you can eject the card – but before doing this, we’ll configure the Raspberry Pi to connect automatically to your wireless network, as this conveniently allows us to set up ownCloud remotely, without needing to hook the Pi up to a monitor and keyboard.
To do this, open up your microSD card in Explorer and open the file dietpi.txt in Notepad. Find the line AUTO_SETUP_NET_WIFI_ENABLED=0 and change the last digit to 1. Save and close the file, then open dietpi-wifi.txt and look for the lines that say aWIFI_SSID='' and aWIFI_KEY=''. Enter your Wi-Fi network name between the first pair of quotes, and your password between the second.
Now you can save the file, eject the microSD card, insert it in your Pi and let the Pi boot.
Configure your Pi
Although you can set up DietPi and ownCloud directly on the Pi, we’ll do it from a Windows system over SSH (the Secure Shell protocol). You need to know the Pi’s IP address, which you should be able to find by checking the “Connected devices” list in your router’s administration interface.
Once you have got the address, open the command prompt on your Windows machine and type ssh firstname.lastname@example.org, entering the Pi’s IP address in place of x.x.x.x. Windows will ask you to confirm you want to connect; type yes. Then enter the Pi root user’s password, which defaults to dietpi. If you don’t get in right away, perform a hard reboot of the Pi – we found this solved an issue when SSH seemed initially unresponsive.
Once you’re connected, the DietPi setup process will complete. We recommend you change the default passwords on the Pi when prompted – just make sure you pick something you can remember, as the passwords you choose will be used as the defaults for any installed applications. At the end of the process, you’ll arrive at the DietPi-Software screen from which you can make further changes and install optimised apps.
We suggest you start by assigning your Pi a static IP address to ensure your cloud server will always be accessible at the same address. To do this, key down to DietPi-Config and press Return, then key down to Network Options: Adapters and press Return again.
Now key up to WiFi and press Return, then select Change Mode. Key down to Copy and press Return: the Pi will now always use your current IP address. In your router’s management interface, set the address to “reserved” to ensure that the router never tries to give it a different one.
Press the right arrow key to select Ok, then press Return; finally, key down to Apply and press Return to restart the network service.
Install ownCloud on the Pi
Now it’s time to return to the DietPi-Software launch screen. This time key down to Software Optimised and press Return to open the list of available applications. It’s a long list, including desktop GUIs, media centres, web servers, Spotify – and ownCloud, which you’ll find as item 47 in the Cloud / Backups section. Press Space to select it, then Tab to highlight Ok and press Return.
You’ll be returned to the DietPi-Software screen. Key down to Install and press Return to download, unpack and set up ownCloud, along with the web server and database software on which it relies. When the process completes, let the Pi reboot.
Once the Pi has restarted, switch back to your web browser, then type x.x.x.x/owncloud, replacing “x.x.x.x” with your Pi’s IP address. Use “admin” for the username, with the password you set earlier (or “dietpi” if you didn’t change the password) to log in.
ownCloud is now up and running on your Pi, and the service should be accessible to any user on your local network. You can use it in a browser, or install the ownCloud desktop client, which runs on various versions of Linux as well as Windows and macOS – you’ll find the installers at owncloud.org/download. If you want to make ownCloud accessible from outside of your network, see opposite.
Setting up Apache on Windows
Setting up ownCloud on Windows is less straightforward than doing so on the Pi. In fact, ownCloud doesn’t even work with some of the most popular web server and database packages on Windows. Luckily, Windows 10 includes the Windows Subsystem for Linux (WSL), which allows us to use Linux components instead.
To get started, you might need to install the subsystem: to do this, right-click the Start button and select Windows PowerShell (Admin). When the UAC prompt appears, confirm that you want to make changes to your PC and then type this command into the PowerShell window:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Once the subsystem is installed, check it’s running by opening the Services console and selecting “LxssManager”: if it’s not, right-click its name and select Restart from the menu.
The next thing you need to do is install a Linux distribution. There are several to choose from in the Microsoft Store but, as we’ve already set up ownCloud on a Debian-based system on the Pi, we’ll use the Debian-based Ubuntu here. Use the search box in the Store app to locate Ubuntu and install it; when the installation completes, reboot your PC.
Once your computer has restarted, reopen PowerShell with Admin rights and enter Ubuntu . The subsystem will perform some background tasks and then ask you to create a Unix user. Provide a username and password.
There’s one last thing to do before you start downloading apps, and that’s update the software catalogues: to do this, type sudo apt update and press Return (providing your password if requested).
You can now install the Apache web server by typing sudo apt install apache2 -y and pressing Return. The -y switch tells Apache not to ask for confirmation, so the process will complete without interruption. When it’s done, run the following commands, each on its own line, to enable the optional web server modules required by ownCloud:
sudo a2enmod rewrite
sudo a2enmod headers
Now restart the Apache web server with sudo service apache2 restart. Check that the server is running properly by opening a browser window and pointing it at http://localhost – you should see the Apache2 Ubuntu Default Page.
Setting up MariaDB
Now the web server is running, let’s install the MariaDB database engine. You can do this by entering:
sudo apt install mariadb-server mariadb-client
Installation only takes a few seconds. When it’s complete, enter these commands to start the database server and launch the configuration process:
sudo /etc/init.d/mysql start
MariaDB will ask for the root password – but there isn’t one yet, so just press Return and, when asked if you want to create a root password, press Y. Enter the new root password, press Return, then repeat the process.
MariaDB will now ask if you want to delete anonymous users. Press Y then press it again when asked if you want to disallow remote login, and a third time to remove the test database. Finally, press Y to reload the tables; a moment later, you’ll be ejected from the setup routine.
Now log in using your new root account. Normally, you’ll be able to do this by simply typing mysql -u root –p. However, if you’re denied access, you might need to update some permissions by entering the following commands on separate lines:
sudo mysql -u root
update user set plugin='' where User='root';
It should only be necessary to apply this fix once. Once you’re in, create a database called “owncloud” by entering the following command at the MariaDB prompt:
CREATE DATABASE owncloud;
You now need to make sure the root user can access your new database. Type the following and press Return, replacing PASSWORD with the password you created:
GRANT ALL ON *.* to 'root'@'localhost' IDENTIFIED BY 'PASSWORD';
Type \q and press Return to quit the MariaDB prompt.
Setting up ownCloud on Windows
At last, it’s time to download and install ownCloud. Switch to Apache’s default web content folder by typing cd /var/www/html; now point your web browser at download.owncloud.org/community and check for the most recent build of ownCloud. At the time of writing, that was 10.4.1, but there may be a newer release by the time you read this.
To download this, enter sudo wget https://download.owncloud.org/community/owncloud-10.4.1.zip, changing the number to the latest version if appropriate.
Once the file has downloaded, you’ll need to decompress it. First, install the unzip package with sudo apt install unzip -y, then enter sudo unzip -q owncloud-10.4.1.zip (again, changing the version number if required). This extracts the application to a subfolder called “owncloud”; switch to that now (by entering cd owncloud) and create a subfolder within it for your cloud data by entering sudo mkdir data.
Finally, you need to set the appropriate permissions on the “owncloud” folder so it can be accessed and managed via ownCloud. To do this, enter the following two lines at the command prompt:
sudo chown -R www-data:www-data /var/www/html/owncloud/
sudo chmod -R 755 /var/www/html/owncloud/
The ownCloud software is now fully installed… but, if you try to access it in a browser, you’ll just see a listing of its index page. That’s because we also need to install the PHP processor that interprets and renders the code – and before doing this, we need to add another software repository reference to the list of locations that Ubuntu checks when installing apps at the command line. To do all of this, enter each of the following lines in turn:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2 php7.2-cli php7.2-fpm php7.2-opcache php7.2-curl php7.2-mbstring php7.2-pgsql php7.2-zip php7.2-xml php7.2-gd php7.2-intl php7.2-mysql
Finally, restart the web server by entering sudo service apache2 restart. Next, open a browser window and point it at localhost/owncloud; you should now be given the ownCloud setup screen.
All that’s left is a little bit of setup. Enter an admin username and password; these should preferably be different from those you set in MariaDB, as they’ll only be used for logging in to ownCloud. Leave the data folder setting as it is, then in the four boxes below that deal with the database connection, use “root” for the username, your password, “owncloud” as the database name and “localhost” as the host. Click the option to use MySQL/MariaDB, followed by Finish Setup.
The new user account will be created and ownCloud will deliver you to a login screen, where you can use the same username and password as you just specified to log in. As on the Raspberry Pi, you can now access ownCloud via the web from anywhere on your local network, or install the desktop client from owncloud.org/download . If you want to be able to access your cloud remotely, then follow the steps below.
Accessing your cloud remotely
When you first set up ownCloud, it will only be accessible within your local network. If you want to access it from the outside world, you’ll need to configure your router to forward incoming web connections to the computer running your ownCloud server. On our Plusnet router, we achieved this by clicking Settings followed by Port Forwarding, then selecting “HTTP Server (World Wide Web)” from the Game or Service menu, and the name of the computer we want to direct it to from the Device menu. The process may be slightly different on your router, so you might need to dig through the menus.
Once you’ve done this, you can connect to the computer hosting your ownCloud service by pointing a web browser at the external IP address of your router. However, ownCloud itself will, by default, only accept connections from within your network. To change this, navigate to the ownCloud configuration folder on your server (at /var/www/owncloud/config/) and edit the config.php file. You can do this using the nano text editor by entering this command:
sudo nano config.php
Add the domain you just set up to the trusted_domains section at the top of the file. Press Ctrl+X to quit and press Y when asked if you want to write out the code to the existing file.
You’ll probably also want to sign up with a dynamic IP service, so you can access your ownCloud server by entering a memorable name, rather than a numeric address. There are several dynamic IP services to choose from, but we’ll go with No-IP, which offers a convenient free plan. Sign up at noip.com by providing your email address and a password, and picking a suitable domain name – we chose pcpro.hopto.org. Confirm your email address by clicking the link it sends to your inbox; if you’re using Windows, install the Dynamic Update Client using the provided link, so that it can notify the No-IP servers every time your router’s IP address changes.
If you’re running ownCloud on DietPi, type dietpi-config at the command prompt and press Return to launch the setup tool. Key down to Network Options: Misc and press Return, then key to No-IP and press Return. Select Ok and press Return to set up the service. When it’s finished installing, select the same No-IP option to set it up, then enter the email address and password you used to create your No-IP account. Your domain name will be detected and your IP address will be registered.
Consumer choice and the payment experience
A software provider's guide to getting, growing, and keeping customersDownload now
Prevent fraud and phishing attacks with DMARC
How to use domain-based message authentication, reporting, and conformance for email securityDownload now
Business in the new economy landscape
How we coped with 2020 and looking ahead to a brighter 2021Download now
How to increase cyber resilience within your organisation
Cyber resilience for dummiesDownload now