How to install NextCloud on your Raspberry Pi? (2 ways)

If you want to keep your data safe, and not hosted by someone else, NextCloud is a great app to try
In this post I’ll show you what is NextCloud and how to install it on your Raspberry Pi

How to install NextCloud on your Raspberry Pi?
NextCloud is a web app, so it’s possible to install it on any device
On Raspberry Pi you have two main methods to do this :
– Installing NextCloudPi, a custom Raspbian image with everything ready to use
– Installing NextCloud in Raspbian, on your existing Raspberry Pi installation

After a short introduction about the NextCloud features, I’ll give you the step-by-step installation guide for both versions
This way you can follow the one that fit the best your needs
Finally, I’ll give you a few tips to start with NextCloud

NextCloud introduction

What is NextCloud?

You probably know Dropbox or Google Drive
Basically, the goal of NextCloud is to offer the same thing, but keeping the control of data on your own server
And it’s free!

You may also know OwnCloud, it’s the same thing (it’s even the same developer)
You can install NextCloud on many platforms, including Linux and therefore the Raspberry Pi

NextCloud features

NextCloud offer many features as soon as you install it:

  • Main features:
    • Files hosting
    • Pictures manager
    • Contacts
    • Calendar
    • Notes
    • Tasks manager
    • News feed reader
  • Desktop and mobile clients for automatic synchronization
  • Some integration is possible (calendar, mail, LDAP …)
  • Users and rights management
  • HTTPS and server side encryption

It’s already a good tool, but that’s not all 🙂
You can download and install extensions (or “Apps”) to add new features from the community

For example, I’m using the “Passwords” extension to store my passwords safely on my network
To check the apps available before installing NextCloud, you can check the NextCloud Apps store here

NextCloud technology

As many of the open-source apps out there, NextCloud code is available on GitHub
They are using web languages like PHP and JavaScript, so it’s easy to install on any device

On the official website, you can also find appliances for specific needs : Virtual Machine, Docker image or Snap package

For Raspberry Pi, we’ll use the source code and the NextCloudPi image, a custom Raspbian image to simplify the NextCloud installation
Docker can also be another solution if you want to try (docker pull NextCloud), I didn’t test it

NextCloud installation

The easy way: NextCloudPi

What is NextCloudPi?

NextCloudPi is a custom image of Raspbian Lite, with NextCloud and all the dependencies preinstalled on it
So it’s easy to get started with NextCloudPi

You can check the NextCloudPi website here for more information
It’s the perfect method of you want to try NextCloud or use a Raspberry Pi mainly for this

You can always install other things after, as it’s a classic Raspbian Lite distribution

Download the image

The first thing to do is to download the latest version of NextCloudPi for the installation :

  • Download the Raspberry Pi version of NextCloudPi from the OwnYourBits server
    There are two versions available: RPi or RPi_BerryBoot
    I’ll show you with the first one
  • Click on the RPi folder and download the image file on your computer (ex: NextCloudPi_RPi_03-09-19.tar.bz2)
  • Extract the image from the archive
    It depends on your operating system, but probably something like right-click > Extract here
    On Windows, you’ll need WinRAR or 7zip to extract it

Flash the SD card

Now that you have downloaded the image, we can flash it on a new SD card:

  • If needed, download and install Etcher
    Etcher is a free tool to easily flash SD card with any Linux image
  • Start Etcher, a windows like this one shows up
    etcher menu
  • Click on the first button and browse to the image location
  • Insert your SD card in your computer and select it in the second item (automatically done by Etcher generally)
  • Then click on “Flash!” to start the SD card creation
  • After a few minutes, your SD card is ready to use

First boot

Insert the SD card in the Raspberry Pi and start it
After a few seconds, you’ll get the login prompt

first login nextcloudpi

Use the default Raspbian login and password:

  • Login: pi
  • Password: raspberry

Then you have to configure the network :

  • Ethernet: it’s working directly if you have a DHCP server
  • Wi-Fi: You need to use raspi-config to configure it
    sudo raspi-config
    Then go into Network options > Wi-Fi and follow the setup wizard

Finally, I recommend starting the SSH service and use it to finish the installation:

  • Start the SSH service
    sudo service ssh start
  • Find the Raspberry Pi IP address
  • Connect via SSH
    On Windows, you’ll need to install a software like Putty
    On Linux/macOS it’s available directly: ssh pi@IP
    Login and password are the same as above

Update the system

From there, I recommend updating the system
It’s not mandatory if you are doing a quick test of NextCloudPi, but as it’s a custom image, it can be a little outdated

To do this, use the following commands:
sudo apt update
sudo apt upgrade
sudo reboot

You’re now ready to move to the NextCloud configuration

NextCloud configuration

NextCloudPi web interface

NextCloudPi is available through a web interface that you can use to configure it
I’ll show you how to enable it, but you can absolutely use the text configuration tool directly if you want

  • Run the NextCloudPi configuration tool
    sudo ncp-config
  • Click on “CONFIG”
  • Scroll down to “Enable WebUI” and press enter
  • Confirm by writing “yes” in the confirmation window
  • Exit the configuration tool

Apache restarts and the web interface is now available at: https://<RASPBERRY_IP>:4443

This is just the NextCloudPi configuration page, not the NextCloud page

Activate NextCloud

  • Open the https://IP:4443 URL in your browser
  • You’ll probably get an HTTPS certificate error, ignore it for now
    You can always install a Let’s Encrypt certificate later if you want
  • A login form shows up
    Enter the default credentials:
    • Login: ncp
    • Password: ownyourbits
  • You’ll now see the activation page, it looks like this:
  • Both user names are “ncp” but you need to note the two passwords for the following steps
    The first one is the NextCloudPi password, to configure NextCloudPi
    The second one is the NextCloud password, to access NextCloud
  • Then click on “Activate”
  • The NextCloud activation starts
    In my first test it took 15min, and the second one it was instant
    So wait if needed, but I probably had an issue in my first install
  • Finally, you get the success message, NextCloud is ready to use

NextCloud first login

If I remember correctly, you are redirected to the ncp config page
But you don’t need it for now
You can access NextCloud directly at https://<RASPBERRY_IP>

NextCloud login form

Enter the login (ncp) and the second password you noted in the previous steps
Then click Log in

The main NextCloud page shows up in your browser:

NextCloud default home page

Congrats! NextCloud is ready to use
I’ll come back to the NextCloud usage in the last part of this guide

Update NextCloudPi

One last thing you can do before starting to use NextCloud is to update NextCloudPi
On the login screen we had a warning saying that NextCloudPi is outdated
Now that NextCloud is configured, you can do this update (I was unable to do it before that)

The update is easy, just run:
sudo ncp-update

If you’re happy with this installation method you can skip the following part and read the last one about the NextCloud usage

The custom method: install it on Raspbian

Why install it on Raspbian?

This second method is perfect if you want to add NextCloud to your current Raspberry Pi installation, without losing anything you already have
With this way, you can also keep the control about everything (for example Apache and PHP versions, Raspbian version, NextCloud version)

Also, if you already have Raspbian and Apache/PHP, you can quickly test NextCloud by extracting files in your /var/www folder, and remove it immediately if NextCloud is not for you

Raspbian installation

If you don’t have Raspbian yet, you need to start here
Follow this Raspbian installation guide if you need help in doing this

But basically you need to:

  • Download Raspbian (Lite is fine)
  • Flash the SD card with Etcher
  • Insert the SD card in the Raspberry Pi and start it
  • Do the network configuration
  • Update the system
  • Enable SSH

Then you’re ready to move to the next step

NextCloud prerequisites

Before installing NextCloud, there are a few prerequisites to have on your system
NextCloud needs a web server with Apache, MySQL (MariaDB) and PHP
And it also needs a few PHP modules

Use the following commands to install everything
sudo apt install apache2 mariadb-server libapache2-mod-php
sudo apt install php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip

Wait a few minutes for the installation to finish, and you’re now ready to install NextCloud

Notice: At the time I write these lines, the latest version of NextCloud needs PHP 7.1, and Raspbian only have PHP 7.0 available in the repository
I made the choice to take an older versions of NextCloud, compatible with PHP 7.0
But you can also try to install PHP 7.1 from sources if you absolutely want the latest version

NextCloud installation

Download NextCloud

You now need to download and extract the NextCloud archive:

  • Go to the Apache web folder
    cd /var/www/html
  • Get the NextCloud link here
    Remember to check the PHP requirements to make sure your current installation is compatible with the version you take
  • In my case, I downloaded the 15.0.8 version
    sudo wget
  • Extract the file with unzip
    sudo unzip
    I’m showing you with the zip file as it’s easier to extract, but you can also get the .tar.bz2 archive from the NextCloud website
  • As we use root to extract files, we need to change the folder permissions to allow Apache to access it:
    sudo chmod 750 nextcloud -R
    sudo chown www-data:www-data nextcloud -R

NextCloud is almost ready to use, but we firstly need to create a MySQL database to store its data

MySQL configuration

After the MariaDB server installation, it creates a root user you can use only from the command line
For NextCloud, I recommend creating a new user and a dedicated database:

  • Connect to MySQL with root
    sudo mysql
  • Create the new user
    CREATE USER 'nextcloud' IDENTIFIED BY 'password';
    Replace “password” by a strong password
  • Create the new database
    CREATE DATABASE nextcloud;
  • Give all permissions to the new user on this database
    GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@localhost IDENTIFIED BY ‘password’;
    Same thing here, just replace “password”with the previous password
  • Save and exit

The database is ready for the end of the NextCloud installation

NextCloud configuration

You can now access the NextCloud configuration page and finish the setup:

  • Open the following URL in your browser: https://IP/nextcloud
    Replace the “IP” with the Raspberry Pi IP address
  • A form like this shows up (first part):

    Choose a username and password for NextCloud
  • The second part looks like this:

    Enter the credentials we just created in MySQL
    – User: nextcloud
    – Password: “password” (your password)
    – Database: nextcloud
    – Host: localhost
  • Then click “Finish setup” and wait a few minutes

You’ll directly get to the NextCloud home page
It looks like the one with NextCloudPi, but there are fewer apps enabled by default

In the main menu you only get these icons:

All the other apps can be enabled from the NextCloud app store (Calendar, Contacts, …)

NextCloud usage

In this part, I’ll give you a little more details about the NextCloud interface
So you can start quickly to use it, and discover everything in a few minutes

Web interface

The main interface is intuitive, and you’ll probably find what you are looking for without more explanations

As I already said, NextCloud use apps to provide features, like on your phone
In the top bar, you’ll find the main menu, to switch to another App
Each app has a custom design, with or without left menu to access more sub sections

In the following sections I will introduce the three main submenus of the administration panel
To access it, click on the icon at the extreme right in the top bar (your avatar, probably the first letter of the username for now)
In the menu, you’ll get mainly 3 options:

  • Settings: to configure everything on NextCloud, from your personal profile to the server configuration
  • Apps: to see which apps are already installed, remove some or install new features
  • Users: NextCloud can manage multiple users to have a personal storage for all the family members or employees

I’ll introduce each of this three parts now


In the “Settings” submenu, you can configure many things, with two categories:

  • Personal configuration: profile, security (two-factor authentication for example), themes, …
  • Administration: with an administrator account, you can also configure things for all users like email server for notifications, encryption, appearance (company logo for example), etc …

For each sub category, you get an intuitive interface with often a short explanation about the page, so I don’t think you’ll need more from me
If you have any question about the configuration, you can check the NextCloud administrator manual, or ask your question in the comments


The second menu is more interesting, with the apps catalog
In the “Your apps” section, you can check in a few clicks which apps you are using and which ones are installed but disabled

Then, the next entries are here to find and install new apps, with one submenu by category: Customization, Files, Games, Integration, …

For each app, you can check directly if it’s an official app, and install it easily by clicking on “Download and enable”
Generally, the new app will appear directly in the top bar of NextCloud


Finally, you can also manage users and groups on NextCloud
In the “Users” menu, you can create as many users and groups that you need, and flag it as administrator or not

Groups are useful in some apps
For example, you can create a group “IT” and share a folder to anyone in the group from the “Files” app

It’s also possible to import users from an LDAP or other sources like Linux users
You’ll need to install the corresponding app to use these features

Desktop apps

The web interface is not the only way to use NextCloud

From the official website, you can download NextCloud for desktop
It’s available for Windows, macOS and Linux

The goal of this desktop app is to synchronize your files between your computer and the NextCloud server (like with Dropbox for example)

During the installation, enter the server address (something like http://IP/nextcloud, or http://IP for NextcloudPi)
Then log into your account and grant access to the app
The last step is to configure how the app handles synchronization:

The first sync will start, and you’ll keep a NextCloud companion in the system tray to check the synchronization status
As soon as you add a new file in your folder, NextCloud synchronize files instantly

Android and iOS apps

The same thing is available on your phone (Android and iOS)
It also provides a mobile friendly interface to use NextCloud
Here is the demo video provided by NextCloud for Android:

Remote access

As it’s supposed to be a cloud server, you’ll probably want to forward a port on your Internet router to access the NextCloud server

It’s possible with your own domain name or a service like NoIP if you have a dynamic IP address
In this case, I highly recommend installing an SSL certificate (Let’s Encrypt) and maybe use a two-factor authentication app to block brute force attacks

You’ll find the documentation about SSL and Apache configuration to do this in the Installation on Linux manual

Additional storage

The main interest in NextCloud is to have an unlimited storage space, as you are the host
But on Raspberry Pi you’re limited by the SD card size
Even if you can easily get more space than with free providers, it’s often not enough to compete with their premium offers

If you want to store large files, it’s possible to add an external storage to your Raspberry Pi, a USB disk for example or even a remote storage (Dropbox, Google Drive, Amazon, other local server)
You’ll find all the documentation here to configure this on your server


As for any storage idea on Raspberry Pi, remember that the Raspberry Pi SD card is not the safest storage method
If your SD card crash, you can lose everything on NextCloud
So remember to make regular backups to another storage (another Pi, a NAS, a USB disk, …)

Files are located in the NextCloud folder, data subfolder
For example, for the admin user, they are probably in /var/www/html/nextcloud/data/admin/files/

So, make a backup of /var/www/html/nextcloud/data and you’ll be fine
You can also make an entire backup of the nextcloud folder and the database, to have a chance to reinstall it the same way as it is now
Check this tutorial for more information on how to backup a Raspberry Pi efficiently



That’s it, I think we have seen a good overview of what NextCloud can do on your Raspberry Pi, and how to install it by two different methods

I’m pretty impressed by the server performance
I have bad memories of NextCloud on a physical server, with slow access and high load average
But for now it seems to work absolutely fine on Raspberry Pi, no load and no lag, great news!

I’ll probably try to keep it installed on one of my Raspberry Pi and see with a more intense usage how it works

Patrick Fromaget

I'm the lead author and owner of My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

13 thoughts on “How to install NextCloud on your Raspberry Pi? (2 ways)

  1. In the installation of Nextcloud on Raspbian, please include the following step before installing apache2 and the php libraries.

    sudo apt update
    sudo apt upgrade

    Or else mysql wont work

  2. Hi Patrick,

    When I get to this step:

    Give all permissions to the new user on this database
    GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextcloud’@localhost IDENTIFIED BY ‘XXX’;
    Same thing here, just replace XXX with the previous password

    I get an error saying “you have an error in your syntax – check your version of MariaDB’s manuals.” I’ve copy-pasted the command exactly except to change the XXX to the password I chose. I did not remove the single quote marks. Unfortunately I’m not familiar with MariaDB and although I did consult their manuals, I haven’t yet figured it out. I also tried IDENTIFIED BY PASSWORD and that didn’t work either.

  3. Hi, everything worked out for me until I tried to boot from the [512 GB] SD card (OK: download NextCloudPi for SD, OK checksum, OK flashing to SD card with etcher) – all on Ubuntu Linux 18.04 LTS.

    The boot process ends after a second with a “kernel panic”. Journal cannot be found and VFS cannot be installed.

    I have a Raspberry Pi 2. I only found one discussion on this issue with someone who encountered the same problem: he succeeded by booting without screen and then connecting via ssh. But he never really figured out what the problem was.

    Any ideas what to do? Thanks in advance!

    1. I had the same problem and solved it by setting a root password to mysql root, exit mysql and then log in with the mysql -u root -p, when prompter enter the password, drop the user created in the first step and type the statement instead of copy and paste it into mysql. It worked fine for me after that.

    1. sudo apt install php7.3-gd php7.3-json php7.3-mysql php7.3-curl php7.3-mbstring php7.3-intl php-imagick php7.3-xml php7.3-zip

      Note that the imagick package is php and not php7.3 all the others just add a 7.3 after php.

  4. The issue with the following line:

    Give all permissions to the new user on this database
    GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextcloud’@localhost IDENTIFIED BY ‘XXX’;

    Is if you “cut and paste” the line to enter, that code example on the webpage has “smart quotes” not single quotes.

    Also, your instructions don’t seem to ever start the Apache web server. After configuring the database, I got a screen full of error messages talking about missing db elements, packages, etc. I corrected the issue by restarting the raspberry pi, but all I really needed to do is restart the webserver to pickup the db bits.

    Right now I’m waiting for the applications to install…

  5. I have 2 main issues.
    1st issue, I enabled web gui at ncp-config. When i reboot it just goes to command prompt but shows NextcloudPi v1.26.2 is up to date. How do i bring up gui locally on pi.
    2nd issue. When i try to access through browser, i login with default ncp username and password. It attempts to login then shows this error:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
    More information about this error may be available in the server error log.

    I have apt-update and apt-upgrade and ncp-update successfully

  6. I also have trouble with Chrome
    Your connection is not private
    Attackers might be trying to steal your information from (for example, passwords, messages, or credit cards). Learn more

    Help improve Chrome security by sending URLs of some pages you visit, limited system information, and some page content to Google. Privacy policy normally uses encryption to protect your information. When Google Chrome tried to connect to this time, the website sent back unusual and incorrect credentials. This may happen when an attacker is trying to pretend to be, or a Wi-Fi sign-in screen has interrupted the connection. Your information is still secure because Google Chrome stopped the connection before any data was exchanged.

    You cannot visit right now because the website sent scrambled credentials that Google Chrome cannot process. Network errors and attacks are usually temporary, so this page will probably work later.

Leave a Reply to Joshua Cancel reply

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

Recent Content