Set up your own cloud
Tutorials – Nextcloud
Get all the benefits of cloud storage and calendars without governments and megacorps spying on you.
Maybe you've heard this line before: "There is no cloud, just other people's computers." Indeed, if you've been to a Free Software-related event recently, you may even have a sticker with those words on it, courtesy of the Free Software Foundation Europe [1]. And it's a good point: "cloud computing," despite all the hype, is simply about handing over control of your data and resources to someone else. It's not actually especially new, but a bunch of technologies mean you can effectively "live" in the cloud, using a low-spec computer and doing all your processing and storage elsewhere. (Well, providing you always have a good Internet connection, of course.)
Still, there are some benefits to the cloud. If you're regularly switching between lots of devices and machines, having easy access to your data is a major bonus. Similarly, you can use cloud services to make regular backups of your data with minimal intervention. So what do you do if you like the technical benefits that cloud services bring, but don't want to hand over all your data to Google, Dropbox, or anyone else? Make your own cloud, of course!
Now, this may all sound extremely complicated when you consider all the things available in typical cloud services: file storage, file sharing, calendars, document collaboration, and more. Fortunately, though, there's an excellent Free Software solution in the form of Nextcloud. This is a spin-off of ownCloud (see the "ownCloud vs. Nextcloud" box for more information on its origins) and really simplifies the job of setting up your own cloud infrastructure. You can set up Nextcloud in your home or office for a "local" cloud installation – or for something more Google or Dropbox-esque, host it on a remote server so you can access your data, calendar, and documents everywhere. Ultimately, like all good things in free and open source software (FOSS), the control remains with you.
ownCloud vs. Nextcloud
Forks in the Free Software world are rarely pleasant but often required in order for progress to be achieved. Look at X.org which forked off from XFree86, for instance, or LibreOffice which forked off from OpenOffice. Both of those forks ended up attracting by far the most developers and were adopted by virtually every Linux distro available. A similar situation exists with ownCloud and Nextcloud.
The ownCloud project was originally created by KDE developer Frank Karlitschek in 2010. One year later, Karlitschek started a company to monetize ownCloud by offering an enterprise version on top of the open source community one. Things seemed to go well for ownCloud until April 2016, when Karlitschek and some other developers left the company and started a fork: Nextcloud.
Karlitschek hasn't elaborated on exactly why he made the fork, but said that some things "could have been better at ownCloud Inc." Many followers speculate that the company Karlitschek founded was losing its community focus as more investors got involved, hence the need for a fork to return to its roots.
In any case, it looks like Nextcloud will be the more popular and developed version for the foreseeable future – at least for FOSS fans. ownCloud has more brand recognition after six years of development, but it remains to be seen whether it can attract new developers, or whether enough damage has been done.
In this article, I will show you how to install, configure, and use Nextcloud. It's not a hugely difficult job, but there are various steps involved, including editing some configuration files. If you're familiar with command-line basics, you should be able to follow. Let's get started.
Setting up the Server
First, you'll need to grab the latest Nextcloud release from the website [2]. Under "Get Nextcloud Server," click the Download button, which will pop up a box offering the most recent release – 10.0.1 at the time of writing. Click the large blue Download button and save the file to your home directory; it's around 45MB.
Next, you need to install some dependencies for Nextcloud. The core requirements are a web server (Apache) along with a database (MySQL or MariaDB) and various PHP libraries. To get everything you need on a Debian-based distro (I'm using Debian 8 here), enter the following as root:
apt-get install apache2 libapache2-mod-php5 php5-sqlite php5-gd php-xml-parser php5-intlphp5-mcrypt php5-curl php5-imagick php-apcphp5-mysql mysql-server ntp
If you're on a different distro, search in your package manager for Apache, MySQL, and those PHP modules – they may have similar names, or you may have to check your distro's documentation. In any case, once you have everything installed, Apache and MySQL should start automatically; if not, try the following as root:
service apache2 start service mysql start
(On systemd distros, try changing service
to systemctl
if the above doesn't work.) You'll then be able to check whether Apache is running by going to the IP address or server's hostname in a web browser – or on the same machine, go to http://localhost
. You should see a default page for Apache, confirming that the web server is running.
Next up is copying the Nextcloud files into your web server's directory. On Debian and Ubuntu-based distros, this can be found in /var/www/html
– but check with your distro's setup in case it's somewhere else. On Debian, you can extract the downloaded .zip
file as root like so:
cd /var/www/html unzip /home/mike/nextcloud-10.0.1.zip
(Change the location to where you downloaded Nextcloud accordingly.) This creates a new directory, /var/www/html/nextcloud
, with all the files for the server. You're almost ready to start Nextcloud's web-based setup wizard, but there are a few Apache tweaks you need to do beforehand. First, change the Nextcloud installation directory's permissions so that the Apache user can modify them:
chown -R www-data:www-data /var/www/html/ nextcloud
Again, www-data
is what Apache runs under in Debian, but it may be different in your specific distro (it's apache
in Fedora and http
in Arch Linux). You also need to give Apache some information about the Nextcloud installation, so create /etc/apache2/sites-available/nextcloud.conf
as shown in Listing 1.
Listing 1
Nextcloud Installation Information
Modify the directory paths accordingly for your Nextcloud installation. Enable this configuration by creating a symbolic link to it like so:
ln -s /etc/apache2/sites-available/ nextcloud.conf/etc/apache2/sites-enabled/nextcloud.conf
Finally, enable some useful modules in Apache with the following commands:
a2enmod rewrite headers env dir mime
and restart Apache:
service apache2 restart
All being well, Apache is now fully set up for Nextcloud, so you can put the command line aside for a while and switch to the shiny web-based setup wizard.
Installation Wizard
In a web browser, go to the hostname of the machine running Apache and add /nextcloud
after it. For instance, if your web browser is running on the same machine as Apache, you can just visit http://localhost/nextcloud
. The setup wizard should appear, prompting you to enter an administrator username and password (Figure 1). Don't forget these! They're like Nextcloud's root account and are essential to perform most configuration jobs.
Underneath the admin box, you'll see a "Performance warning" message. By default, Nextcloud is set up to use SQLite for storage – which is fine for testing, but rather slow for production use. Click Storage & database and choose MySQL/MariaDB underneath. Then enter the root or admin user for your MySQL/MariaDB installation and password; if you're on Debian, you will have created those when you apt-getted the database earlier. Finally, provide a name for the database (e.g., "mynextcloud") and click Finish setup.
If all is well, you'll then land at the main Nextcloud file sharing screen (Figure 2). (A pop-up may appear with links to downloading Nextcloud clients – just dismiss it for now.) And, there you have it, you're ready to use Nextcloud! Well, as the admin user, at least. Obviously, this is not good practice on a day-to-day basis, so your first job is to click the admin drop-down list in the top-right of the interface, and then Users. Here you can enter new usernames and passwords in the empty fields and then click Create.
By default, Nextcloud is set up primarily for file sharing, but you may want to enable much more of its functionality. Click the drop-down menu in the top-left of the web interface, next to the Nextcloud logo, and choose Apps. This is where you can enable various add-ons, so browse around and see what takes your fancy. I especially recommend Calendar, Contacts, and Documents in the Productivity section, bringing Nextcloud much closer to the services offered by Google (Figure 3).
Using Nextcloud and Advanced Tuning
Now you're ready to use Nextcloud for your day-to-day work. Click admin in the top right and then Log out. Now log in as the normal user account you created earlier, and you'll arrive at the file management page. You can now begin using the file storage features: create new folders and upload your files knowing that they're backed up on your own personal cloud. To share a file or folder, click the Share button (two lines connected with dots), which lets you share with other users on the same Nextcloud installation, or indeed pass around a link over the web (be careful with this). By clicking the three separate dots next to a file or folder, you can download, rename, or delete it.
Click Files in the top-left to access Nextcloud's other features; try Calendar first. This brings up a familiar calendar interface, where you can navigate between months and years, click on days to add events, and so forth. You may want to access your calendar from other software as well: click the three dots next to the calendar name (e.g., "Personal") and then Link. This provides a URL that you can then use in WebDAV-compatible calendars.
Also in the top-left menu, try Documents, and click the About.odt
file (Figure 4). As the filename extension suggests, Nextcloud uses the Open Document Format (like LibreOffice), although its editor is rather primitive in comparison. Still, it's more than good enough for basic editing tasks, and multiple users can work on the same document simultaneously (click the Share button at the top).
Depending on your desktop environment, you may be able to access your Nextcloud files via you regular file manager (Figure 5), instead of using the web interface. In Nextcloud, click the top-left menu and choose Files. Then, look for Settings in the bottom-left and click it – a WebDAV box will appear. This is an address you can use in your file manager to access the Nextcloud data via the WebDAV protocol.
Copy it to your clipboard and then try to open a new location in your file manager; the specifics will depend on your desktop. In Nautilus, for instance, hitting Ctrl+L lets you paste in an address. I had to change http://
to dav://
in my instance, but your results may vary depending on the libraries you have installed. If in doubt, check your desktop's documentation.
Nextcloud periodically needs to perform some background tasks to keep it ticking over smoothly. By default, Nextcloud does this whenever a user accesses the web interface, but that's far from ideal. A better solution is to set up a cron job that runs every 15 minutes. Edit the cron table by entering the following:
crontab -u www-data -e
(Change www-data
for the appropriate account for the web server.) Then add this to the bottom:
*/15 * * * * php -f /var/www/html/ nextcloud/cron.php
Back in the Nextcloud web interface, log in as the admin user, click the top-right menu and go to Admin. You'll see a cron section there where you can switch from Ajax to cron for better performance.
In your Nextcloud installation directory, check out config/config.php
. This contains some useful information, such as the username and password that Nextcloud created for its MySQL/MariaDB database – in case you need to perform some manual work. Also worth noting here is the trusted_domains
option, which is where you can specify IP addresses and hostnames that are valid for this Nextcloud installation. You can see that there's already one item (numbered zero) in the list for localhost
, so add more if you want to access it under a different name (e.g., if the hostname on the network is raspberrypi
, add that here).
By default, Nextcloud uses plain HTTP, which works for a simple home network or testing, but if you want to use it in business or over the Internet, you should enable SSL. The Nextcloud installation guide [3] explains how to do this and includes many other pointers for advanced configuration and fine-tuning of your Nextcloud installation. It's well worth checking out.
So, enjoy your shiny new self-hosted cloud, as well as independence from snooping eyes. Let us know how you get on, and what funky skillo things you're doing with your Nextcloud installation! Indeed, you could try hosting Nextcloud on a spare Raspberry Pi (see the box "Dig out that Raspberry Pi!" for details).
Dig out that Raspberry Pi!
Got a spare Raspberry Pi sitting around doing nothing especially useful? Put it to work making backups of your critical data! Yes, Nextcloud will run on the Rasp Pi, but don't expect blazing performance, even on the Raspberry Pi 3. If your Nextcloud installation will be processing vast amounts of data and documents for many different users, the Rasp Pi may be too sluggish – but it's more than adequate for occasional jobs.
I, for instance, have a Rasp Pi plugged in to my router via Ethernet, running Nextcloud from a 16GB SD card. That may not sound like much data, and it's not used for storing videos or music; however, for documents and other work-related files, it's more than spacious enough. With the NextCloud desktop client installed and a link to its shared folder on the desktop, anything saved in there is automatically synced and stored on the Rasp Pi as well – without having to do any extra work.
With all critical data backed up on the Pi, it's not the end of the world if a particular desktop or laptop goes kaput. Switch to a different one, sync up with the Rasp Pi, and all files are accessible via a desktop folder again. Even when testing other operating systems inside a virtual machine, for which no Nextcloud desktop clients are available, the web interface is still there as an option.
Infos
- "There is no cloud" sticker: https://fsfe.org/contribute/spreadtheword.en.html#nocloud
- Download Nextcloud: https://nextcloud.com/install/
- Nextcloud installation guide: http://tinyurl.com/hgpqhe8
Buy this article as PDF
(incl. VAT)