ultimate setup guide for Nextcloud on Raspberry Pi

Table of Contents Prerequisites Required Hardware Necessary Software Preparing the Raspberry Pi Setting Up Raspberry Pi OS Updating System Packages Installing Nextcloud Downloading Nextcloud Setting Up Apache Installing PHP and Extensions Configuring the Database Installing

Written by: David Choi

Published on: January 7, 2026

Table of Contents

  1. Prerequisites
    • Required Hardware
    • Necessary Software
  2. Preparing the Raspberry Pi
    • Setting Up Raspberry Pi OS
    • Updating System Packages
  3. Installing Nextcloud
    • Downloading Nextcloud
    • Setting Up Apache
    • Installing PHP and Extensions
  4. Configuring the Database
    • Installing MariaDB
    • Creating a Nextcloud Database
  5. Finalizing the Nextcloud Installation
    • Adjusting File Permissions
    • Accessing the Nextcloud Web Installer
  6. Post-Installation Configuration
    • Enabling HTTPS with Let’s Encrypt
    • Enhancing Security
  7. Accessing Your Nextcloud Server
    • Configuring Dynamic DNS
    • Accessing Your Nextcloud from a Remote Location
  8. Adding User Accounts and Configuring Storage
    • Creating Users
    • Configuring External Storage
  9. Enabling Useful Apps
    • Calendar App
    • Contacts App
    • Additional Features
  10. Backup and Maintenance
    • Setting Up Automatic Backups
    • Regular Maintenance Tasks

Prerequisites

Required Hardware

  • Raspberry Pi 3 or 4: The Raspberry Pi 4 is highly recommended for performance.
  • MicroSD Card (16GB or larger): Use a high-quality card with Class 10 or UHS rating.
  • External Hard Drive (Optional): For storing larger amounts of data.
  • Power Supply: A reliable power supply rated for Raspberry Pi.
  • Network Connection: Ethernet or Wi-Fi connection for internet access.

Necessary Software

  • Raspberry Pi OS: A lightweight version can suffice.
  • Apache Web Server: For serving your Nextcloud instance.
  • MariaDB or MySQL: For the database.
  • PHP: For script execution.
  • Nextcloud: The main application to install.

Preparing the Raspberry Pi

Setting Up Raspberry Pi OS

  1. Download the Raspberry Pi Imager from the official website.
  2. Insert your microSD card and launch the Imager.
  3. Select “Raspberry Pi OS (32-bit)” and choose your SD card.
  4. Click “Write” to install the OS onto the card.
  5. Once complete, insert the microSD card into your Raspberry Pi and boot it up.

Updating System Packages

  1. Access the terminal and log in.
  2. Run the following commands:
    sudo apt update
    sudo apt upgrade

Installing Nextcloud

Downloading Nextcloud

  1. Navigate to the official Nextcloud website.
  2. Copy the download link for the latest server version.
  3. In your terminal, use wget to download it:
    wget https://download.nextcloud.com/server/releases/nextcloud-x.y.z.zip
  4. Replace x.y.z with the latest version number.

Setting Up Apache

  1. Install Apache by running:
    sudo apt install apache2
  2. Enable Apache’s mod_rewrite module:
    sudo a2enmod rewrite
  3. Restart Apache:
    sudo systemctl restart apache2

Installing PHP and Extensions

  1. Install PHP and required extensions:
    sudo apt install php php-cli php-fpm php-mysql php-zip php-xml php-mbstring php-curl

Configuring the Database

Installing MariaDB

  1. Install MariaDB server:
    sudo apt install mariadb-server

Creating a Nextcloud Database

  1. Launch the MariaDB shell:
    sudo mysql -u root
  2. Create a new database and user:
    CREATE DATABASE nextcloud;
    CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'secure_password';
    GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;

Finalizing the Nextcloud Installation

Adjusting File Permissions

  1. Move the downloaded Nextcloud folder to the Apache root directory:
    sudo unzip nextcloud-x.y.z.zip -d /var/www/
  2. Set ownership and permissions:
    sudo chown -R www-data:www-data /var/www/nextcloud
    sudo chmod -R 755 /var/www/nextcloud

Accessing the Nextcloud Web Installer

  1. Open a browser and navigate to http://your_raspberry_pi_ip/nextcloud.
  2. Follow the on-screen instructions to complete installation.

Post-Installation Configuration

Enabling HTTPS with Let’s Encrypt

  1. Install Certbot:
    sudo apt install certbot python3-certbot-apache
  2. Obtain an SSL certificate:
    sudo certbot --apache

Enhancing Security

  1. Create a .htaccess file in the Nextcloud directory to enhance security:
    cd /var/www/nextcloud
    nano .htaccess
  2. Add security directives.

Accessing Your Nextcloud Server

Configuring Dynamic DNS

  1. Sign up for a Dynamic DNS service if accessing from outside your local network.
  2. Configure your router to update the DNS service with your current IP.

Accessing Your Nextcloud from a Remote Location

  • Use the DDNS address in your web browser.

Adding User Accounts and Configuring Storage

Creating Users

  1. Log into Nextcloud as an admin.
  2. Navigate to Users and add new users.

Configuring External Storage

  1. Go to Settings and click on External storages.
  2. Add your external storage configurations.

Enabling Useful Apps

Calendar App

  • From the settings, enable the Calendar app for scheduling.

Contacts App

  • Enable the Contacts app for managing contacts.

Additional Features

  • Explore and enable more apps from the Nextcloud app store.

Backup and Maintenance

Setting Up Automatic Backups

  1. Use rsync or a similar tool to copy data regularly:
    rsync -A -X /var/www/nextcloud /path_to_backup/

Regular Maintenance Tasks

  • Regularly check for updates, monitor system performance, and clear cache.

This ultimate setup guide provides a comprehensive, SEO-friendly approach to deploying Nextcloud on a Raspberry Pi, ensuring the system is secure and fully functional. Each step is critical to creating a sustainable private cloud storage solution.

Leave a Comment

Previous

how to smoothly migrate from notion to open source note-taking app

Next

top open source video editors for novice creators