how to install nextcloud on raspberry pi

Installing NextCloud on Your Raspberry Pi (2 Ways)

If you click our links and make a purchase, we may earn an affiliate commission. Learn more

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 NextCloud is and how to install it on your Raspberry Pi.

There are two methods to install NextCloud on a Raspberry Pi. The first method is by installing NextCloudPi, a custom image with everything ready to use. The second method is by installing the NextCloud files on an existing Raspberry Pi OS.

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

If you’re new to Raspberry Pi or Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your Raspberry Pi. Click here to get it for free!

NextCloud Introduction

What Is NextCloud?

Nextcloud is a file hosting service that can be self-hosted on a Raspberry Pi. It can be used for file storage obviously, but also has many other features (collaboration, communication, etc.). You can even install plugins on it, so it’s almost unlimited.

You probably know Dropbox or Google Drive. Basically, NextCloud’s goal is to offer the same thing, but allows you to keep control of the data on your server. And it’s free! So it’s a great way to save money with your Raspberry Pi.

nextcloud main menu icons

You may also know about 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 offers 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, etc.).
  • 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 use the “Passwords” extension to store my passwords safely on my network.

Prefer reading without ads and popups?
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In

To check what apps are available before installing NextCloud, you can check the NextCloud Apps store here.

NextCloud Technology

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

Like many open-source apps out there, NextCloud code is available on GitHub.
It uses web languages like PHP and JavaScript, so it’s easy to install on any device.

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

Recommended Hardware for a NextCloud Server

  • Raspberry Pi 5 or Pi 4: I recommend these newer models. I tried with older boards, but it’s often too laggy to browse the web application and synchronize files (at least with my files).
  • Big SD card: I would recommend at least 120 GB. You don’t want to restart from scratch because you didn’t have enough storage for your project. Another option is to plug in a USB drive and use it for the main storage. It may be even be cheaper (check the price here).
  • Backup solution: I will talk about this later, but you need a safety plan. Storing everything on a Raspberry Pi without backups is not a good idea. I’m using the NAS linked above, but if you have a smaller budget, you can use another USB drive for this. Even an old SATA drive in an external case like this one would be fine.

Tip: to store your files, I recommend keeping them on a USB drive rather than an SD card. Personally, I like using a giant USB key because it’s very convenient for the Raspberry Pi (look at this one on Amazon), but any cheap external hard drive will be better than an SD card (I’m using this one for my backups).

NextCloud Installation

There are two different ways to get NextCloud on your Raspberry Pi. I’ll show you both, but I’ll start with the simpler method first.

Note: If you want to see these steps in action, I have a video on NextCloud just for community members. Join here to watch, and get access to 30+ other lessons for Raspberry Pi along with many other benefits!

The Easiest Way: Install NextCloudPi

What Is NextCloudPi?

NextCloudPi is a custom image of Raspberry Pi OS 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 if you want to try NextCloud or use a Raspberry Pi mainly for this.

You can always install other things after, as it’s still a classic Raspberry Pi OS Lite distribution.

Download NextCloudPi

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

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now
  • Visit the official NextCloudPi GitHub page.
  • Scroll down to find the Raspberry Pi version, and download the one for your Pi model.
    nextcloudpi github assets
  • Note: you won’t need to extract the archive if you’ll be using Raspberry Pi Imager or Balena Etcher to flash the image, but you might need to for other tools.

Flash NextCloudPi onto the SD Card

Now that you’ve downloaded the image, we can flash it onto a new SD card:

  • If needed, download and install Raspberry Pi Imager.
    Imager is a free tool to easily flash an SD card for Raspberry Pi with any Linux image.
  • Start Imager, and choose your Pi device.
    raspberry pi imager select device
  • Click Choose OS, and scroll to the bottom to select Use custom.
    When prompted, locate the NextcloudPi zip file you downloaded earlier.
  • Click Choose Storage, and select your SD card or USB drive.
    raspberry pi imager showing nextcloud pi settings
  • Click Next.
    When asked to apply OS customisation settings, choose No.
    (I believe custom settings don’t work properly for this image.)
  • Confirm, and Imager will begin the writing process.

After a few minutes, your SD card is ready to use.

First Boot With NextCloudPi

Insert the SD card into the Raspberry Pi and start it.
Wait a few minutes for NextCloudPi to initialize.

Warning: I could only get NextCloudPi to boot with Ethernet, as Wi-Fi wouldn’t connect. The interface won’t start properly the first time if it can’t download files immediately.

New versions of NextCloudPi require an activation step through its web interface.

Activate NextCloud

  • Open https://nextcloudpi or https://IP 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.
  • After some time, you’ll be redirected to a page looking like this:nextcloud activation screen
  • Both usernames 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”.
    nextcloudpi activation button
  • The NextCloud activation starts.
  • Finally, you get the success message, NextCloud is ready to use:
    nextcloud activation successful

NextCloud First Login

You should be redirected to login, but if not 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.
You can also do it from the web interface (the one with the port 4443).

If you’re happy with this installation method you can skip the following section and skip to the last one about NextCloud usage.

Alternative Method: Install NextCloud on Raspberry Pi OS

Why Install It on Raspberry Pi OS?

This second method is perfect if you want to add NextCloud to your current Raspberry Pi installation, without losing anything you already have

banner raspberry pi os bookworm wallpaper
Raspberry Pi OS

This way, you can also keep control of everything (for example Apache and PHP versions, Raspberry Pi OS version, NextCloud version).

Also, if you’ve already got Raspberry Pi OS and Apache/PHP, you can quickly test NextCloud by extracting files in your /var/www folder, and also remove it immediately if NextCloud is not for you.

Install Raspberry Pi OS

If you don’t have Raspberry Pi OS installed yet, you need to start here.
Follow this Raspberry Pi OS installation guide if you need help in doing this.

But basically, you need to:

  • Download Raspberry Pi OS (Lite is fine).
  • Flash the SD card with Etcher or Raspberry Pi Imager.
  • Insert the SD card into the Raspberry Pi and start it.
  • Do the network configuration.
  • Update the system.
  • Enable SSH.
    It’s not mandatory, but I find it easier to copy/paste the commands from my computer, instead of using the Raspberry Pi directly.

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

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

Wait a few minutes for the installation to finish, and restart Apache to load the new PHP modules:
sudo service apache2 restart
You’re now ready to install NextCloud.

Warning: Be careful when choosing the NextCloud version to install. It can be a mismatch between the NextCloud requirements and the services versions available on Raspberry Pi OS.

For example, if the latest version of NextCloud requires PHP 8, and Raspberry Pi OS only have PHP 7.4 available in the repository, it won’t work.
You may need to either pick an older NextCloud version or install a more recent version of PHP manually (the first option is easier).

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.
    There are many downloads available.
    Look for the Server section, and then the Community Projects subsection:
    download nextcloud server
    You can then copy the link under Archive for the zip file:
    nextcloud community project download server get zip file
    Remember to check the PHP requirements to make sure your current installation is compatible with the version you take.
  • You can also test this command directly, if they don’t change the link it should be fine:
    sudo wget https://download.nextcloud.com/server/releases/latest.zip
  • Extract the file with unzip:
    sudo unzip latest.zip
  • As we used the root user to extract files, we need to change folder permissions to allow Apache to access it:
    sudo chmod 750 nextcloud -R
    sudo chown www-data:www-data nextcloud -R
give apache user permissions to nextcloud files

NextCloud is almost ready to use, but first we 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” with 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 password you set previously.
  • Save and exit:
    FLUSH PRIVILEGES;
    quit

The database is ready for the final step of the NextCloud installation.

More details on how to set up a MySQL server in this other article.

NextCloud Configuration

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

  • Open the following URL in your browser: http://IP/nextcloud
    Replace “IP” with your Raspberry Pi IP address.
  • A form like this shows up (first part):
    nextcloud create admin account and setup details
    If you get any error at this point, that’s probably because some PHP modules are missing, install them with APT to fix the errors before going further.
  • Choose a username and password for NextCloud.
    Warning: make sure to use a long enough username (5 characters or more) and password (10 chars or more). I tried with a simple one, it doesn’t stop the installation, but I couldn’t log in after that. I had to start over with another username and password…
  • The second part asks you where you want to store the NextCloud files.
    Keep the default value if you only have one main partition, or change it to use an external USB drive, for example.
  • Then, the third part is your database configuration.
    Enter the credentials we just created in MySQL:
    – Database account: nextcloud
    – Password: “password” (the password you set above for MySQL)
    – Database name: nextcloud
    – Host: localhost
  • Finally, click “Install” and wait a few minutes.

When it’s done, the form redirects you, but it didn’t do so properly during my tests.
If you get an error, just revisit the URL again:
http://IP/nextcloud
And you’ll get the login form:

nextcloud first login web interface

Sign in with the admin credentials.

Warning: if your login credentials don’t work for some reason, try a different browser.
In my case, I had to use Google Chrome.

Now you’ll get access to the full interface.
It looks similar to the one with NextCloudPi, but there are fewer apps enabled by default.

In the main menu, you only get these icons:

nextcloud main menu 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

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

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

As I already said, NextCloud uses 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 a left menu to access more subsections.

nextcloud top menu

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 personal storage for all the family members or employees.

I’ll introduce each of these three parts now.

Settings

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

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

For each subcategory, 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 questions about the configuration, you can check the NextCloud administrator manual, or ask your question in the community.

Apps

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.

nextcloud apps enabled or disabled

You can also manage the apps updates from there, in a few clicks:

nextcloud apps updates page

Then, the next entries in the left menu are here to find and install new apps, with one submenu by category: Customization, Files, Games, Integration, etc.

nextcloud find new apps to i nstsall

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.

Users

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

Groups are useful in some apps.
For example, you can create a group “IT” and share a folder with 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.

nextcloud download link for desktop app

The goal of this desktop app is to synchronize your files between your computer and the NextCloud server (like the way Dropbox works, 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:

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

Read next: Tired of Raspberry Pi OS? Level up with these top-rated systems.

nextcloud app sync settings

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 to your folder, NextCloud synchronizes 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 domain name or a service like NoIP if you have a dynamic IP address (detailed tutorial here).

In this case, I highly recommend installing an SSL certificate (Let’s Encrypt) and maybe using 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.

Note: This part can be a bit tricky. I have a video lesson available for the community members where I show you how to host a website at home (not Bitwarden, but it’s the same steps). You can join here and watch it directly if you are interested (with 10+ other lessons for Raspberry Pi and many other benefits).

Additional Storage

The main interest in NextCloud is to have 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 external storage to your Raspberry Pi, a USB disk (I love the mini USB keys like this one on Amazon to do this) for example or even remote storage (Dropbox, Google Drive, Amazon, another local server).

You’ll find all the documentation here to configure this on your server.

Backups

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, etc.).

Files are located in the NextCloud folder, the data subfolder.
For example, the admin user, is 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 back up a Raspberry Pi efficiently.


🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Prefer videos over reading? The RaspberryTips Community members get exclusive video lessons every month. Join now and watch them all right away. Get instant access.

Video

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. A third and alternative option is to install NextCloud on FreedomBox, an all-in-one server solution, with just a few easy clicks.

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

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

Whenever you’re ready, here are other ways I can help you:

Test Your Raspberry Pi Level (Free): Not sure why everything takes so long on your Raspberry Pi? Take this free 3-minute assessment and see what’s causing the problems.

The RaspberryTips Community: Need help or want to discuss your Raspberry Pi projects with others who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct help.

Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

You can also find all my recommendations for tools and hardware on this page.

Similar Posts

17 Comments

  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

    1. Hi Jochem,

      Thanks for your feedback
      I wrote it at the beginning, so I think it’s ok, no?

  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. In “The custom method: install it on Raspbian” add tutorial how to enable HTTPS in Apache2.

  6. 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 https://192.168.2.130, 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

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

    Help improve Chrome security by sending URLs of some pages you visit, limited system information, and some page content to Google. Privacy policy
    192.168.2.130 normally uses encryption to protect your information. When Google Chrome tried to connect to 192.168.2.130 this time, the website sent back unusual and incorrect credentials. This may happen when an attacker is trying to pretend to be 192.168.2.130, 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 192.168.2.130 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.

  8. Thank you very much for this detailed and nice explanation! But how do I get the Nextcloud Documents and Media-Files to the external HDD or USB-Drive? Is there a special Boot/ Partition configuration needed as explained in this article? https://docs.nextcloudpi.com/en/how-to-install-nextcloudpi/
    Should we set and mount the linux home folder to a separate drive (other than sd card)?
    Or is the place of the installation independent from the Nextcloud Home Folder?
    These are probably very stupid questions…
    By the way…-Which file system do you recommend for a hard drive?
    Thanks a lot!

    1. I’ve pihole & pivpn on my current setup, will nextcloud cause any conflict to the system? Thanks.

      1. I haven’t tested but Pi-Hole and Nextcloud are using the default HTTP port, so it might be an issue.
        The only way to know is to test 🙂
        Maybe you can use a different port or folder for one of them if it doesn’t work.

Comments are closed.