Tutorial: Raspberry Pi, Nextcloud

What is Nextcloud ?

Nextcloud is a counter model to the typical cloud offerings of large US providers such as Microsoft.

Preliminary Note

In this tutorial, I will use the IP address, gateway and DNS, These settings might differ for you, so you have to replace them where appropriate. You can write the commands below directly in the terminal or remote connect using a SSH client like PuTTY.

Before proceeding further you need to have Raspberry Pi OS Lite / Desktop installed on your Raspberry Pi device. If you don’t already have this, you can use the Tutorial: Installing Raspberry Pi OS to install the Operating System.


  1. Raspberry Pi board
  2. Power supply
  3. Micro SD card 8/16GB
  4. Ethernet cord


1 Update system.

sudo apt-get update
sudo apt-get upgrade -y

2 Configure Network.

sudo nano /etc/dhcpcd.conf

Scroll to the end and the following:

interface eth0
static ip_address=
static routers=
static domain_name_servers=

Press ctrl + x, and then press y + enter to save.

Reboot with:

sudo reboot

3 Installing packages.

sudo apt install apache2 php7.3 php7.3-gd php7.3-sqlite3 php7.3-curl php7.3-zip php7.3-xml php7.3-mbstring php7.3-mysql php7.3-bz2 php7.3-intl php7.3-smbclient php7.3-imap php7.3-gmp libapache2-mod-php7.3 mariadb-server mariadb-client php-mysql

4 Configure Mysql

Secure mysql by setting a root password.

sudo mysql_secure_installation

Enter current password for root (enter for none): <<ENTER

Change the root password? [Y/n] <<Y

Remove anonymous users? [Y/n] <<ENTER

Disallow root login remotely? [Y/n] <<ENTER

Remove test database and access to it? [Y/n] <<ENTER

Create a user and database for Mysql.

sudo mysql -u root -p

We will be creating database called nextclouddb and a user called nextclouduser by running the commands below. Make sure that you replace PASSWORD with a secure password and make note of it for later.

CREATE DATABASE nextclouddb;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'PASSWORD';

5. Nextcloud.

Download & Installing.

cd /var/www/
sudo wget https://download.nextcloud.com/server/releases/latest.tar.bz2
sudo tar -xvf latest.tar.bz2
sudo rm latest.tar.bz2

We now need to create a data directory for Nextcloud to operate in, for the initial setup of Nextcloud

sudo mkdir -p /var/www/nextcloud/data
sudo chown -R www-data:www-data /var/www/nextcloud/
sudo chmod 750 /var/www/nextcloud/data

Configure Apache

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

Within this file enter the following lines.

Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

  <IfModule mod_dav.c>
    Dav off


Press ctrl + x, and then press y + enter to save. And then run:

sudo a2ensite nextcloud.conf
sudo systemctl reload apache2

Now that we have finished with that we can now finally go to Nextcloud itself and begin its installation process. Open your browser and open the following address:

You will now be greeted with the following screen.

Here you will need to type in the Username and Password that you intend to use for your admin account.

Next, we need to specify the details for our database server. To get to these options you will need to click the “Storage & Datbase” option.

Now you need to slect the type of database we want to use. As we are using an SQL server click the “MySQL/MariaDB” option.

Finally we need to enter the details for our database server. There are three bits of information that we will need to enter.

  1. The username for the user that will interact with our database server. If you are using the same information we used, this setting should be set to nextclouduser.
  2. The password that you set for the above user.
  3. The final option you will need to set is the database name. If you have been following our guide this will be nextclouddb.

Once you are happy with this, press the “Finish Setup” button, please note this can take some time to complete as it finalises your setup.


Leave a Reply