Personal cloud storage on the Orange Pi

Set up the personal cloud service

One cool and practical project you can do on an Orange Pi or a Raspberry Pi is to set up a free, personal and “on-premise” version of Dropbox. This will allow you, among other things, to share files between your different devices. Additionally, you can automatically upload any new pictures from your phone to the cloud storage. In this tutorial you will learn to install the private cloud server software, configure it and sync files from a mobile device. I tested these steps on the Orange Pi and I assume this will also work on the Raspberry Pi. We will store the data on and external device, like a USB flash drive or external HDD, connected to the Orange Pi.

The could server software we will use is Nextcloud. Nextcloud is very similar to Dropbox, the main difference being that Nextcould is open source and completely free. The next steps are loosely based on a Nextcloud installation guide for the Raspberry Pi. Also, I used the official Nextcloud documentation. Before installing Nexcloud, we need to install some dependencies. We will basically create a LAMP server. First update the package list:

sudo apt-get update

Then we need to install apache:

apt-get install apache2

To check the installation, type in the IP address of your Orange Pi in the browser of any device connected to your home network. You should see this page:

apache-orange-pi
Next, install PHP and a database system. We have a few choices of databases: SQLite, MySQL and MariaDB. Here I will use MariaDB. You can also use MySQL. To install MySQL on the Orange Pi, please see this post. To install MariaDB:

sudo apt-get install mariadb-server

MariaDB will ask you to create a root password, which you will need further in the Nextcloud installation. Then, to install PHP:

sudo apt-get install php5 libapache2-mod-php5 -y
sudo apt-get install php5-gd
sudo apt-get install php5-mysql
sudo apt-get install php5-curl
sudo apt-get install php5-memcached

Next, let’s download and install Nextcloud:

wget https://download.nextcloud.com/server/releases/nextcloud-11.0.3.zip
sudo mv nextcloud-11.0.3.zip /var/www/html
cd /var/www/html
sudo unzip -q nextcloud-11.0.3.zip

In the following step, we will configure Nextcloud to that it stores data on an external device, such as a flash drive or hard disk. After connecting the external storage via USB, type in:

sudo fdisk -l

Based on the output, looking at the disk size and type, identify the external storage. On my Orange Pi it is called “sda1”:

fdisk-orange-pi

Then, format this disk, mount it and give ownership to the HTTP user:

sudo mkfs -t ext4 /dev/sda1
sudo mkdir /disk
sudo mount /dev/sda1 /disk
sudo mkdir -p /disk/nextcloud/data
sudo chown www-data:www-data /disk/nextcloud/data
sudo chmod 750 /disk/nextcloud/data

Next, give ownership to the HTTP user on the Nextcloud directory:

sudo chown -R www-data:www-data /var/www/nextcloud/

Now type in the IP of your Orange PI, followed by “/nextcloud” (e.g. 192.168.0.12/nextcloud) in the browser of any device on your home network. You should see the Nextcloud configuration screen:

nextcloud-setup

Type in a username and password, that you will need later to connect from your phone. Expand “Storage & database”. Under “Data folder” put “/disk/nextcloud/data”. In the database section type in the root credentials and pick a database name of your choosing.

Synchronize files from the phone

To transfer files from the phone you need to install the Nextcloud client app from the App Store or Google Play, depending on your device. After installation, open the app and type in the server address as before (e.g. 192.168.0.12/nextcloud) and your username and password:

nextcloud-login

Allow the app access to SD, if asked. Once logged in, you can either upload files manually or choose to auto-upload files to the cloud. To enable auto-upload touch the burger menu to the top left and select “Auto upload”:

nextcloud-burger-menu

Next touch the cloud symbol next corresponding to the camera folder:

auto-upload-nextcloud

That’s it, happy clouding!

Temperature sensor on Orange Pi with Python code

Comments

  1. What version of opi did you use ? It’s opi zero h3 suitable for this install ?
    Thanks.

    • Hi John, I have a Orange Pi Plus 2e which has an H3 CPU. I think it should also work on an OPI Zero.

Leave a Reply

Your email address will not be published / Required fields are marked *