Build a Pi Nextcloud server
Christian Cawley has had enough of third-party cloud storage. Is a nextCloud-powered cloud server on Raspberry Pi the solution?
Christian Cawley has had enough of thirdparty cloud storage. Is a NextCloud-powered server on the Pi the solution? Yes.
Staying in control of your own data is vital. It goes deeper than personal data, too. All of those files and folders in your personal cloud storage with Google Drive, Dropbox, Box, Microsoft OneDrive and many others are subject to various degrees of – let’s say oversight – that you might not be entirely comfortable with.
The solution is to run your own cloud server: a home-based storage system that can be accessed from anywhere. Available 24/7 for syncing data across your devices, mobile and desktop, such a server is best connected directly to your router for reliability. And you can do this with a Raspberry Pi and a suitably sized storage device. While several projects are available for building your own Raspberry Pi cloud server, perhaps the most complete solution is Nextcloud.
If you’re sick of paying for cloud storage or just find the whole idea a bit suspicious, self-hosting your own always-accessible cloud makes sense. With your own hardware and hosted on your own network, the cloud will be completely private. Throw in optional VPN support and even encryption to improve privacy. Selfhosting is also cheaper. For example, a 2TB drive on Amazon is considerably cheaper than the same level of storage with Dropbox or Box.
Rolling your own home-based cloud storage solution will also give you faster speeds. You don’t need to rely on internet connections and put up with online traffic and virtual server bottlenecks. The cloud is hosted on your own network, which means that you can sync data based on your router’s Ethernet or Wi-Fi speed.
Nextcloud solutions
Several cloud servers are suitable for Raspberry Pi. These include ownCloud, Nextcloud and Seafile. You can even do the whole thing from scratch with the Pi Cloud system, installing various server and VPN software to create a barebones cloud solution on Raspberry Pi OS.
Nextcloud has been chosen for this build. It comes with two installation options, configuration is clear rather than esoteric, and it’s open source. When used on your own hardware, Nextcloud is also free to use.
There are three main options for installing Nextcloud on Raspberry Pi: the NextCloudPi image, the Nextcloud Ubuntu appliance for Raspberry Pi, and manually installing on an existing Raspberry Pi OS installation.
While a Raspberry Pi 3 can be used, it’s considerably slower than a Raspberry Pi 4. As such, the later Pi is recommended, with at least a 4GB SD card – 128GB cards are around £15. We ran NextCloudPi on a Raspberry Pi 4 with 8GB of RAM and a 32GB SD card. You’ll also need a monitor and keyboard attached for the initial setup, although these can be detached, and the server ran as headless after configuration. Ethernet is recommended for speed and reliability.
Get your Pi in the sky
You can take your pick of methods for installing Nextcloud on Raspberry Pi. NextCloudPi is a preconfigured Nextcloud image for Raspberry Pi (and other SBCs) that features everything you need to manage your own cloud data server.
Built with Debian Buster and Nextcloud 19.0.2, NextCloudPi has a setup wizard, web interface, dynamic DNS support, USB automount and everything else you might need to run a cloud server. It also supports Nextcloud mobile apps for mobile data syncing.
NextCloudPi also offers a choice of installation options. You can install it the usual way with an image writing tool such as Etcher or Raspberry Pi Imager; install with Etcher and then move the boot partition to USB; flash direct to USB for use on a Raspberry Pi 4; or use
Berryboot to flash to SD or a USB device. This guide is more concerned with configuration and use of a Nextcloud server on a Raspberry Pi with the standard SD card installation.
If you’re installing using the Raspberry Pi Imager, click Choose OS to select the downloaded IMG, Choose Storage to select your SD card, then Write. After flashing, boot the SD card in your Raspberry Pi and login with the Raspberry Pi OS default credentials, these should be changed as soon as possible.
To use wireless networking, enter sudo raspi-config
and choose 2 Network Options. Select N2 Wireless LAN and choose the correct country, then enter your router’s SSID and password. Next, go to 5 Interfacing Options and enable SSH.
Exit raspi-config, then make a note of the IP address for wlan0 with ip addr . You can then access the Nextcloud server via SSH from another computer using
ssh pi@
The Pi can then be disconnected from the display and monitor at any point now.
Either directly in the terminal or with an open SSH connection, enable the Nextcloud web interface:
sudo ncp-config
Select CONFIG then scroll to nc-webui. Erase the no and type yes instead, then Enter. Go Back, then Finish to exit. From your main computer, open https://
To use the Nextcloud web interface, open https:// [YOUR IP ADDRESS].
Ubuntu Appliance
Using Ubuntu Appliance (https://bit.ly/LXF280nextcloudappliance) is a more straightforward approach. Start by writing the downloaded IMG file to your SD card with Raspberry Pi Imager (as above) or Etcher, then boot the Pi with the Nextcloud image.
While this starts up, configure your Ubuntu One account (see walkthrough, page 59, for details) for SSO (single sign-on) and storing encryption keys for SSH. Before proceeding, create SSH keys:
ssh-keygen -t rsa
Select where to store the key or tap enter to accept the default location. Input a passphrase when asked.
Retrieve the key using
cat ~/.ssh/id_rsa.pub
(Windows users can employ WinSCP to create an SSH key or open a terminal in Windows Subsystem for Linux and use the above commands.)
Copy the created key string into the SSH Keys page on your Ubuntu One account, then click Import SSH Key to save it.
On the Raspberry Pi, tap Enter when prompted. The next step is to configure networking. With Ethernet connected, simply move on to the next screen by highlighting Done with the arrow keys and tapping Enter. If you’re using Wi-Fi, configure this instead.
Next, input your Ubuntu One email (see the walkthrough on page 59 again). Shortly after, the account should be verified and the IP address of your Nextcloud server displayed.
Along with the IP address, you should see your Ubuntu One SSO name. This can be used to access the Nextcloud server over SSH, in the style: username@
Full access can be enjoyed via the browser. Using your main computer, open http://nextcloud.local in your browser (or the IP address displayed on your Raspberry Pi). Upon first access you’ll be prompted to create a
server administrator account. This is vital for the administration of the Nextcloud server, enabling you to configure user access.
Terminal install
If you prefer to use your own Raspberry Pi OS for Nextcloud, it can be installed and set up in the terminal. Raspberry Pi OS Lite (https://bit.ly/lxf280-pioslite) is recommended for this.
Prerequisites for this approach are the installation of the Apache, PHP and MySQL, along with some PHP modules: sudo apt install apache2 mariadb-server libapache2mod-php sudo apt install php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip
Next, open the web folder:
cd /var/www/html
Check the download path (https://bit.ly/LXF280nextcloudlatest) for the version of Nextcloud that you plan to use.
sudo wget https://download.nextcloud.com/server/ releases/nextcloud-xx.x.x.zip
When the download has completed, extract with:
sudo extract nextcloud-xx.x.0.zip
With this done, configure folder permissions:
sudo chmod 750 nextcloud -R sudo chown www-data:www-data nextcloud -R
This ensures that anyone with an account can access your Nextcloud. You can then set up the MySQL database:
sudo mysql
Create the MySQL user nextcloud, ensuring that a strong password is set.
CREATE USER ‘nextcloud’ IDENTIFIED BY ‘password’; Next, create the database itself:
CREATE DATABASE nextcloud;
The nextcloud user should now be given all permissions to the database, again changing ‘password’ to match the one you set earlier:
GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextcloud'@localhost IDENTIFIED BY ‘password’;
Finish with
FLUSH PRIVILEGES; quit
You should now be able to access the Nextcloud server from a desktop browser using the IP address of your Raspberry Pi, https://
When prompted, create an administrator account, and input the credentials for MySQL. Click Finish setup and wait while everything is finalised.
Changing clouds
With Nextcloud up and running on the Raspberry Pi, you can connect to it from any browser on your network (or beyond, with a static IP address from your ISP or a tool like No-IP or another dynamic DNS service). There’s even a mobile app for Android and iOS that can be used to sync files from your phone to the Pi-powered Nextcloud. If you don’t use the Play Store, the Android Nextcloud app is also available on F-Droid.
In the browser-based interface you’ll find a bunch of menus, presented like a cross between a smart TV and a typical cloud storage UI. From here you can upload files manually from your computer, or via a client tool – available for Linux, macOS and Windows. While command line configuration options are available, everything you need to manage your Nextcloud is available in the browser.
Beyond the default photos, files, contacts, calendar and various other productivity tools, Nextcloud can give you almost anything you need via a collection of programs. Some of these are preinstalled, others can be added in the Apps screen. This covers everything from tools like Collabora Online to new themes, social network integrations, and much more.
To find out more, it’s worth taking the time to follow this tutorial with your preferred Nextcloud installation method and explore what’s available. Nextcloud has evolved into a vast and impressive cloud productivity environment. Consequently, this guide only scratches the surface of what is possible with Nextcloud on a Raspberry Pi.