Installing Nextcloud on a Raspberry Pi is Easy! Follow Along to Get Your Own Personal Cloud Storage Solution.

In this guide, you’ll learn how to install and set up Nextcloud on your Raspberry Pi. This will allow you to create your own personal cloud storage solution with all the benefits of secure file syncin …


Updated August 23, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


In this guide, you’ll learn how to install and set up Nextcloud on your Raspberry Pi. This will allow you to create your own personal cloud storage solution with all the benefits of secure file syncing and sharing across multiple devices.

Installing Nextcloud on a Raspberry Pi can be done in a few simple steps, as long as you follow the instructions carefully. Here’s an outline of what you need to do:

  1. Update Your System Before you begin installing any new software, it’s always a good idea to update your system to ensure everything is up-to-date and compatible with each other. Open a terminal window and enter the following commands:
sudo apt-get update
sudo apt-get upgrade
  1. Install Apache and PHP Nextcloud requires a web server (Apache) and a scripting language (PHP) to run properly. To install them, use the following command:
sudo apt-get install apache2 php libapache2-mod-php php-curl php-gd php-intl php-mbstring php-xml php-zip
  1. Install MariaDB Nextcloud also requires a database to manage user accounts and data. To install MariaDB, use the following command:
sudo apt-get install mariadb-server

During the installation process, you will be prompted to set up your database root password. Make sure to remember this as you’ll need it later.

  1. Install Nextcloud Now that you have all the necessary prerequisites installed, you can download and install Nextcloud itself. To do this, follow these steps:

    1. First, create a new directory for Nextcloud in your web server’s root folder:
      sudo mkdir /var/www/nextcloud
      
    2. Change the owner of the directory to the Apache user so you can write to it later:
      sudo chown -R www-data:www-data /var/www/nextcloud
      
    3. Download the latest version of Nextcloud using wget (or any other method you prefer):
      cd /tmp
      wget https://download.nextcloud.com/server/releases/latest.tar.bz2
      
    4. Extract the downloaded archive to your web server’s directory:
      sudo tar -xjf latest.tar.bz2 -C /var/www/nextcloud --strip-components=1
      
    5. Set the correct permissions on the extracted files:
      sudo chown -R www-data:www-data /var/www/nextcloud
      sudo find /var/www/nextcloud -type d -exec chmod 750 {} \;
      sudo find /var/www/nextcloud -type f -exec chmod 640 {} \;
      
    6. Create a symbolic link from your web server’s root directory to the Nextcloud installation:
      sudo ln -s /var/www/nextcloud /var/www/html/nextcloud
      
  2. Configure Apache To allow your Raspberry Pi to serve Nextcloud over HTTPS, you’ll need to configure Apache with a SSL certificate. First, make sure the ssl module is enabled:

sudo a2enmod ssl

Then create a new configuration file for Nextcloud in Apache’s sites-available directory:

sudo nano /etc/apache2/sites-available/nextcloud.conf

Add the following content to this file (replace yourdomain.com with your actual domain):

<VirtualHost *:80>
    ServerName yourdomain.com
    Redirect permanent / https://yourdomain.com/
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on
    SSLProtocol -all +TLSv1.2
    SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem
    
    ServerName yourdomain.com
    DocumentRoot /var/www/nextcloud
    
    <Directory /var/www/nextcloud>
        Options +FollowSymlinks
        AllowOverride All
        
        <IfModule mod_dav.c>
            Dav off
        </IfModule>
        
        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
    </Directory>
</VirtualHost>

Save and close the file, then enable the new configuration:

sudo a2ensite nextcloud.conf
sudo systemctl restart apache2

Now your Raspberry Pi is ready to serve Nextcloud over HTTPS!

  1. Configure Nextcloud Open a web browser and navigate to https://yourdomain.com/nextcloud. You should see the Nextcloud setup wizard. Follow the prompts to set up your admin user, database details (using the root password you set earlier), and any other options you prefer.

  2. Set Up Auto-Update Nextcloud can automatically check for updates and apply them. To enable this feature, open the Nextcloud config file:

sudo nano /var/www/nextcloud/config/config.php

Add or modify the following line to set your admin user’s email address (replace you@example.com with your actual email):

'updatechecker' => array(
    'enabled' => true,
    'email' => 'you@example.com',
),

Save and close the file.

That’s it! You’ve successfully installed Nextcloud on your Raspberry Pi and set up a personal cloud storage solution. Now you can access your files from any device with an internet connection, securely and privately.