Project notes · 18 ago

How to create a Raspberry Pi-Cloud

Raspberry pi 5
Raspberry pi 5

Introduction

I've always wanted to have my own personal cloud - something reliable, private, and always accessible without relying on services like Google Drive or Dropbox. That's how I ended up building my own Nextcloud server using a Raspberry Pi and a 2TB SSD. In this post, I’ll walk you through my whole setup process, share some tips I learned along the way, and show you how you can build your own!

Index

  1. Hardware needed

  2. Base installation and setup

  3. Setting up Nextcloud

  4. Securing access with Cloudflare Tunnel

  5. Backup and security measures

  6. Final optimizations

  7. Conclusion and future improvements

1. Hardware Needed

Here's the hardware I used:

I installed Raspberry Pi OS directly onto the SSD, skipping the microSD card completely after the first boot.

2. Base Installation and Setup

Step 1: Install Raspberry Pi OS on the SSD

Step 2: Basic setup

sudo apt update && sudo apt upgrade -y
sudo systemctl enable ssh
sudo systemctl start ssh
ssh pi@<your_pi_ip>

Optional: If SSH complains about keys:

rm .ssh/known_hosts

Step 3: Install Docker and Portainer

curl -sSL https://get.docker.com | sh
sudo docker volume create portainer_data
sudo docker run -d -p 9443:9443 \
--name=portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest

Access Portainer at https://your_pi_ip:9443

3. Setting Up Nextcloud

Using Portainer made the deployment easy. I followed a template based on Pi-Hosted:

Docker Compose settings:

services:
  nextcloud:
    image: linuxserver/nextcloud
    container_name: nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/New_York
      - MYSQL_PASSWORD=raspberry1
      - MYSQL_ROOT_PASSWORD=raspberry1
    volumes:
      - /home/wwwroot/data:/data
    ports:
      - 5443:443
    restart: unless-stopped

After starting the container, Nextcloud was available at https://your_pi_ip:5443

4. Securing Access with Cloudflare Tunnel

Instead of exposing ports on my home network, I used Cloudflare Tunnel:

cloudflared tunnel create nextcloud-pi

5. Backup and Security Measures

Some useful commands:

sudo -u www-data php occ app:list
sudo -u www-data php occ app:remove <app_name>
sudo tail -f /var/www/nextcloud/data/nextcloud.log

Extra tip: To access recovery partitions or backups via SSH:

sshfs pi@192.168.1.63:/dev/sda1 /mnt/recovery

6. Final Optimizations

Inside config.php of Nextcloud, I added:

'memcache.local' => '\\OC\\Memcache\\APCu',
'filelocking.enabled' => true,
'memcache.locking' => '\\OC\\Memcache\\APCu',

This improved the overall performance significantly.

Also, I made sure to limit upload size and optimize database settings for better performance.

7. Conclusion and Future Improvements

Setting up my own cloud server with a Raspberry Pi was one of the best DIY projects I’ve done. It’s stable, fast, and extremely satisfying to manage your own data privately.

Future upgrades I’m considering:

← All articles