Into the cloud with a Pine64, NextCloud and DietPi

Dropbox is all well and good – good enough, in fact, that I pay for it. But it does have occasional irritations. And if you want to play around with cloud-based stuff, what could be better than having a cloud of your own?

I’ve just received a LattePanda Alpha single board computer on which I’m running Ubuntu 18.04. I won’t go into that too much (that could be a separate post) other than to say: a) I want to use it as a main development machine for a lot of my electronics & robotics stuff – not least because it has an onboard microcontroller; and b) I hit a snag running Dropbox on it. Can’t remember the exact nature of the problem, but it got me going in another direction.

The requirement

‘Cloud computing’ is usually translated as ‘someone else’s computer’. But it’s possible – and indeed pretty easy – to use your own. (Whether you accept that term ‘easy’ after reading this is up to you.)

I like to be able to share a number of files among a group of computers – desktop and laptop Macs, a Win7 laptop, a Win10 VM, an Ubuntu VM and now an Ubuntu SBC (the Alpha). These files include program files (my Arduino setup, for example, has the Arduino directory and its libraries in a Dropbox folder), and libraries. Mostly, I’ve achieved this by putting the files in folders within the Dropbox directory and, in some cases, using symbolic links locally. That latter bit turned out to be prescient because moving the files without breaking stuff just means changing a few symlinks.

The thing is, I only need these files at home. Dropbox’s ability to continue syncing when I’m on the road isn’t important any more because, well, I’m never on the road.

So I ordered a RockPro64 and various extras, including two 1TB SATA drives, with the intention of setting up a NAS box. This could sit on my home network and give access to all the files. Simple.

But there’s one advantage of the Dropbox approach I’ve always liked – that every machine has its own copy of the files. This provides redundancy and means you can use the files even if, for some reason, the network connection is down.

OwnCloud vs NextCloud

Then I heard about ownCloud. I could set up a cloud server on a machine on my network and have all the important advantages of Dropbox. In fact, there are additional advantages, such as being able to use more than one server.

And then I heard about NextCloud

Look, this stuff was all new to me. I know many of you will think this is all old news, but I have trouble catching up sometimes. So, for anyone else like me, here’s a very short synopsis. OwnCloud was started by some German guys. It became successful and opened a US operation. The founder, Frank Karlitschek, became fed up with the corporate culture that overwhelmed ownCloud and left (along with 90% of the developers) to set up NextCloud. Originally, the code bases were identical and you could even use the client from one platform with a server on the other. But now NextCloud seems to be developing at a healthier rate and so that’s the one I went for.

Choosing a platform

First, though, I needed something on which to run the server. My RockPro64 still hasn’t been despatched but I was keen to try out NextCloud.

Then I remembered something. A rummage through my ‘mistakes I made on KickStarter’ cupboard turned up a dusty box containing a Pine A64 board. I bought it along with an LCD screen and other extras via the original KickStarter campaign. And I never got it to work. OS support for the board was pathetic back then and I just didn’t know enough to overcome this hurdle.

But things have moved on. The Pine64 people learned a lot of lessons and now produce excellent products. And we now have projects like Armbian and DietPi. These offer well-supported and well-crafted versions of Linux for a wide variety of boards. DietPi, in particular, is interesting because it’s very stripped down, eliminating a lot of cruft but also providing optimised packages for useful solutions – such as NextCloud.

Don at the Novaspirit Tech Youtube channel (great channel, I recommend subscribing) has an excellent step-by-step video on getting NextCloud set up on a Raspberry Pi. (He has an earlier one, too, on doing the same for ownCloud). This uses DietPi, and it’s when I realised that DietPi supports the Pine64 that I figured this should work for me.

Not going well

So, I downloaded the DietPi image and burned it to a 32GB SD card in the time-honoured fashion. Most of what follows pretty much echoes Don’s process. But I hit some snags and did a couple of things slightly differently.

I’d already partitioned and formatted (as Ext4) a 120GB SSD drive using GParted on the Alpha, so I didn’t need to do the steps Don details relating to that.

When you first boot into DietPi, it prompts you to change the default passwords. Before starting on the NextCloud installation there were some things I needed to install/configure. First, while I’m in France, I used a US keyboard (I need # more than I need £). DietPi, for some reason, defaulted to a UK keyboard. So I went through the localisation to select a 104-key generic keyboard with basic US settings.

Next, because I like to have ifconfig available, I installed net-tools (yes, DietPi is that slim).

Then I used the dietpi-software program to select and install NextCloud. And that’s where I ran into my first big problem.

Everything went fine installing the necessary packages (Lighttpd, MariaDB etc). But when the time came to install NextCloud itself I started getting serious-looking error messages saying stuff like:

An unhandled exception has been thrown:
Error: Class 'Memcached' not found in /var/www/nextcloud/config/config.php

Uh-oh. It seems this is the result of a change by NextCloud. Eventually the installation crapped out completely.

A discussion here provided some answers. Long story short: once you’ve encountered these errors, you need to enter the following (by the way, I’m doing all of this as root):

sed -i "\|cp '/var/www/nextcloud/config/config.sample.php'|d" /DietPi/dietpi/dietpi-software
rm /var/www/nextcloud/config/config.php
rm /var/www/nextcloud/occ
dietpi-software install 114

But, as we’ll see, there’s a smarter way.

Bad to worse

From that point, things got worse. I’ll save you the whole sorry tale except for one note of caution.

The SSD drive I’m using is powered solely by the USB port through a USB-to-SATA cable. I was providing the power to the Pine64 from my bench power supply (it was just handy). But I hadn’t noticed that I had amps limited to 1A. Most of the time, the Pine64 + SSD pulled around 500-600mA. Just occasionally I noticed it peak at just over 800mA (I wasn’t watching carefully). And then, just as it looked like everything was installed and running, the machine crashed and rebooted. Except that it wouldn’t reboot.

I cranked up the power supply to 3.2A (its maximum), reflashed the SD card with DietPi and started again from the beginning. And this is the sequence of events that worked for me.

  1. Started up DietPi and did the password thing and the installation of net-tools and keyboard config.
  2. Edited /etc/stab to mount the SSD. I chose the mount point /media/datastore. Then did a ‘mount -a’ to ensure it was mounted.
  3. Before installing NextCloud, I used the first of the commands above (the sed one). It’s the only one you need at this stage if you haven’t already encountered the errors.
  4. Installed NextCloud via DietPi’s menus. This time it went fine.
  5. As detailed in the video above, there can be problems with the MySql/MariaDB user setup. So at this stage I did the following. This is in the video, but I’m repeating here for convenience and some of the steps Don went through aren’t necessary if you haven’t already tried & failed. I’ve kept the prompts in – my input is in bold and, obviously, you put in your own passwords(!):
root@pine64 # mysql -u root -p{mysql_password}
MariaDB [(none)]> grant all privileges on nextcloud.* to 'nc_admin'@'localhost' identified by '{chosen_password}';
MariaDB [(none)]> flush privileges;

At this point, it should be working.

By the way, the DietPi folks are on to the problem that caused the NextCloud installation issues. By the time you read this it’s possible that issue will be solved and you won’t need to do the sed thing.

Finishing up

The next step was to connect to the server from a browser. My Pine64 had the IP address, given to it by my router. So I connected via the URL:

However, this just provided me with a login page, with fields only for username and password. This is not what I was expecting. You should get a page with options to configure the MySQL username and password (the ones I set up above), a username and password for the NextCloud administrator and the path to your storage (/media/datastore in my case).

I moved the /var/www/nextcloud/config/config.php to /var/www/nextcloud/config/config_backup.php and refreshed the page – and all was good. I could configure as necessary.

But then came another hiccup. I want the Pine64 at a fixed IP address. I went into /etc/network/interfaces and configured a static IP of for the eth0 interface (should have done this first). But when I tried connecting via the browser to NextCloud it threw up an error about ‘Accessing NextCloud from untrusted domain’.

So I opened up /var/www/nextcloud/config/config.php. In there is a section that I needed to edit:

trusted_domains' => array (
    0 => 'localhost',
    1 => '',

I downloaded the client app for macOS from NextCloud and tried it from my iMac. Worked great. Then I tried installing the client app (nextcloud-client) from Ubuntu’s app store on the Alpha. Not so good. It threw up an error about being unable to create a sync journal. So I uninstalled it and headed over to NextCloud and ended up following the instructions here.

And now I’m a happy bunny. All is working well. This is just a test installation until my RockPro64 arrives, but getting that going should be a snap after working through all this.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.