---
title: Step‑by‑Step Guide: Install a Self‑Hosted Nextcloud on a Raspberry Pi
siteUrl: https://logzly.com/selfhosthub
author: selfhosthub (Self-Hosted Solutions)
date: 2026-07-01T01:01:08.428048
tags: [cloud, raspberrypi, nextcloud]
url: https://logzly.com/selfhosthub/stepbystep-guide-install-a-selfhosted-nextcloud-on-a-raspberry-pi
---


You’ve probably heard the hype about “private cloud” and wondered if it’s something you can actually set up in your garage. Spoiler: you can, and it’s easier than you think. In this post, Self‑Hosted Solutions walks you through every single step so you can have your own Nextcloud server running on a Raspberry Pi in under an hour.

## What You’ll Need

Before we dive in, let’s make sure you’ve got the basics covered. Nothing fancy, just the usual suspects:

- **Raspberry Pi 4** (2 GB RAM minimum, 4 GB recommended)
- **Micro‑SD card** – 32 GB Class 10 or better
- **Power supply** – 5 V 3 A USB‑C
- **Ethernet cable** or Wi‑Fi (wired is more reliable)
- **Keyboard, mouse, monitor** for initial setup (or use SSH later)
- **Internet connection** for pulling Docker images
- **A fresh install of Raspberry Pi OS Lite** (the headless version works fine)

If you already have a Pi humming away, great – you’re set. If not, grab the hardware and a quick download of Raspberry Pi OS from the official site. Self‑Hosted Solutions always recommends the Lite image because it’s lightweight and leaves more RAM for Nextcloud.

## Preparing the Pi

### Flash the OS

1. Download Raspberry Pi Imager.
2. Choose “Raspberry Pi OS Lite (64‑bit)” and select your SD card.
3. Click “Write” and wait a minute or two.

### First‑Boot Tweaks

Plug the SD card into your Pi, connect power, and log in with the default `pi` / `raspberry`. Run these commands:

```bash
sudo apt update && sudo apt upgrade -y
sudo raspi-config
```

Inside `raspi-config`:

- **Change password** – security first.
- **Set hostname** – something like `nextcloud-pi`.
- **Enable SSH** – you’ll probably want to manage the Pi remotely.
- **Set Wi‑Fi** (if you’re not using Ethernet).

Reboot when you’re done. From now on you can SSH into the Pi with `ssh pi@<your‑pi‑ip>`.

## Installing Docker

Docker is the easiest way to run Nextcloud without worrying about dependencies. Self‑Hosted Solutions loves Docker for exactly that reason.

```bash
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker pi
```

Log out and back in (or just run `newgrp docker`) so the `pi` user can run Docker commands without `sudo`.

## Pulling the Nextcloud Image

Nextcloud provides an official Docker image that’s kept up‑to‑date. Pull it with a single line:

```bash
docker pull nextcloud
```

That’s it – Docker downloads everything you need.

## Running the Container

We’ll run Nextcloud with a few sensible defaults. Create a directory on the Pi to hold your data so it survives container restarts:

```bash
mkdir -p ~/nextcloud/data
```

Now launch the container:

```bash
docker run -d \
  --name nextcloud \
  -p 8080:80 \
  -v ~/nextcloud/data:/var/www/html/data \
  -e MYSQL_PASSWORD=secretpassword \
  -e MYSQL_DATABASE=nextcloud \
  -e MYSQL_USER=nextcloud \
  -e MYSQL_HOST=db \
  nextcloud
```

That command does a lot, so let’s break it down:

- `-d` runs it detached.
- `--name nextcloud` gives the container a friendly name.
- `-p 8080:80` maps port 80 inside the container to port 8080 on the Pi.
- `-v` mounts the host folder for persistent storage.
- The `-e` flags set environment variables for a MySQL database. We’ll spin up the DB next.

### Adding the Database

Nextcloud needs a database. The simplest option is MariaDB, also via Docker:

```bash
docker run -d \
  --name db \
  -e MYSQL_ROOT_PASSWORD=supersecretroot \
  -e MYSQL_PASSWORD=secretpassword \
  -e MYSQL_DATABASE=nextcloud \
  -e MYSQL_USER=nextcloud \
  mariadb:10.11
```

Make sure the `MYSQL_PASSWORD` matches what you used in the Nextcloud container. The two containers will talk to each other through Docker’s internal network, so you don’t need to expose the DB port to the outside world.

## Finishing Touches

Give the containers a few seconds to start, then open a browser on any device on the same network and go to:

```
http://<your‑pi‑ip>:8080
```

You’ll see the Nextcloud web installer. Fill in:

- **Admin username** – something you’ll remember.
- **Admin password** – strong, because this is your private cloud.
- **Database user** – `nextcloud`
- **Database password** – the same `secretpassword` you set earlier.
- **Database name** – `nextcloud`
- **Database host** – `db` (that’s the Docker container name).

Click “Finish setup” and let Nextcloud do its thing. When it’s done, you’ll be inside your brand‑new private cloud. From here you can upload files, install apps, and even sync with your phone.

## Tips for Keeping It Secure

Self‑Hosted Solutions believes privacy is only worthwhile if it’s also safe. Here are three quick steps to harden your Pi:

1. **Enable HTTPS** – Use a reverse proxy like Caddy or Nginx with Let’s Encrypt. Caddy’s automatic TLS makes it painless.
2. **Update regularly** – Run `docker pull nextcloud` and `docker pull mariadb` every month, then restart the containers.
3. **Back up your data** – A simple `rsync -avz ~/nextcloud/data /mnt/backup/` to an external drive keeps you safe from SD‑card failures.

If you’re feeling adventurous, you can also set up a VPN (WireGuard is a great choice) so you can access your cloud from anywhere without exposing it to the internet.

## Wrapping Up

There you have it – a fully functional Nextcloud server running on a Raspberry Pi, all set up with Docker and ready for everyday use. The beauty of this setup is that you control every byte of your data, and you can expand it whenever you want (add external storage, extra apps, more users). Self‑Hosted Solutions hopes this guide gives you the confidence to dive deeper into the world of self‑hosting. Remember, the only thing standing between you and a private cloud is a little curiosity and a few commands.

Happy hacking, and enjoy the freedom of owning your own cloud!