So in this post, we will be showing you how to setup and configure a Raspberry Pi as Nextcloud server, and this can be used as your Personal cloud services like Google Drive or Dropbox. This can also be called a raspberry pi cloud server.

Nextcloud is a suite of client-server software for creating and using file hosting services. Nextcloud application functionally is similar to Dropbox. Unlike Dropbox, Nextcloud does not offer off-premises file storage hosting. Nextcloud is free and open-source, which means that anyone is allowed to install and operate it on their own private server devices.

What Are We Covering Today?

1. Installation of PHP and Apache web server

2. Installation of NextCloud

3. Moving the nextcloud Data Folder

4. Increasing Maximum upload size

5. Changing the apache2.conf file setting

6. Port forwarding using Dataplicity

7. Connecting an External Hard Disk Drive(HDD)

Don’t be panic, I have covered all of the above steps very precisely and if you face any problem during the installation, feel free to contact me here

1. Steps to Install PHP and Apache

To run the Nextcloud on Raspberry Pi, we have to install PHP and Apache web server. we won’t be going too depth for this installation steps. If you want to learn more about the web server setup on a Raspberry Pi, then you can read this tutorial about web server installation on a Raspberry Pi

Step 1: SSH into your Raspberry Pi and run the following command to update and upgrade your Pi to Latest version of Raspbian

sudo apt-get update && sudo apt-get upgrade

Step 2: Now run the command to install Apache Web server on Your Pi

sudo apt-get install apache2

Step 3: To Install the Latest Version of PHP, enter the following command

sudo apt-get install php

Step 4: Now the last step is to start the Apache Web server, do that by the following command

sudo service apache2 start

2. Steps to Install Nextcloud

Installation of the Nextcloud is quite simple on a Raspberry Pi. Just run some bunch of commands and your installation will be done

Step 1: To begin installation, first move to our html directory by the following command

cd /var/www/html

Step 2: Now run the following command to download and extract the latest version of nextcloud

curl https://download.nextcloud.com/server/releases/nextcloud-13.0.4.tar.bz2 | sudo tar -jxv

Step 3: Now we have to create a directory so that nextcloud can operate. Initially, we will keep our nextcloud in /www/html directory. do that with the following command

sudo mkdir /var/www/html/nextcloud/data

Step 4: Now we need to change the ownership of the entire nextcloud folder, do that by the following command

sudo chown -R www-data:www-data /var/www/html/nextcloud/

Step 5: Now we need to change the permission of the nextcloud folder, do that by the following command

sudo chmod 750 /var/www/html/nextcloud/data

Step 6: and finally we have done with all the Installation steps of the nextcloud. Its time to begin the nextcloud itself and begin the installation process. for that open your web browser and type the IP Address of your Raspberry Pi /nextcloud as. Remember to replace the IP address with your own Pi IP address

192.168.0.100/nextcloud

Step 7: Now you may see a screen with basic installation steps

Step 8: Enter any username and password you want, to be safe enter a strong password because we will use this cloud storage outside our Local Network

Step 9: Now click on Finish Setup to complete the Installation process

3. Steps to Move the Nextcloud data folder

In this step, we will move our Nextcloud directory to the /var/ directory so that the nextcloud/data should not be in the /var/www/html directory.

Step 1: To get started, let’s make a new directory to /var location so that we can keep our nextcloud data in that. do that by the following command

sudo mkdir -p /var/nextcloud

Step 2: Now we have to move our data files into the directory we created in step 1. run the following command to move our data directory

sudo mv -v /var/www/html/nextcloud/data /var/nextcloud/data

Step 3: In this step, we have to do some changes into the configuration files, so that we can point to our new data directory. Open the configuration folder by the following command

cd /var/www/html/nextcloud/config

Step 4: Now for the safety purpose, let’s make a backup of our config.php file by the following command

sudo cp -p config.php config.php.bk

Step 5: So let’s do some changes in the config.php file by the following command

sudo nano config.php

Step 6: within this file, we have to change the following line

'datadirectory' => '/var/www/html/nextcloud/data',

To

'datadirectory' => '/var/nextcloud/data',

Step 7: Now we can save and quit out of the file by pressing Ctrl+X then Y and then Enter. Now you can refresh the web browser to see the changes.

4. Steps to increase Nextcloud’s maximum upload size

By default, the maximum upload size in the nextcloud is 2MB which is not enough. we can increase the upload size by doing some changes in the php.ini file.

Step 1: To increase the maximum upload, we need to edit the php.ini file. do that by the following command

sudo nano /etc/php/7.0/apache2/php.ini

Step 2: Now change the following line in the php.ini file

post_max_size = 8Mupload_max_filesize = 2M

To

post_max_size = 1024Mupload_max_filesize = 1024M

Step 3: Now save the setting by pressing Ctrl+X then Y and then Enter

Step 4: So finally we have updated the configuration file, restart the Apache web server by the following command

sudo service apache2 restart

5. Steps to change the apache2.conf file configuration

Now we need to edit the apache2.conf file so that it can allow the .htaccess overriding. since we have installed nextcloud in the default apache2 directory which is /var/www/html

Step 1: open the apache2.conf file in nano editor by the following command

sudo nano /etc/apache2/apache2.conf

Step 2: Now you can use Ctrl + w to find the block of code. Replace the following block of code

<Directory /var/www/>
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</Directory>

To

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

Step 3: Now save the setting by pressing Ctrl+X then Y and then Enter

Step 4: In this step, we need to restart the apache web server, enter the following command for that

sudo service apache2 restart

6. Port Forwarding using Dataplicity

As you know that, if you want to access your cloud server outside the network then you have to do port forwarding. In our case, we will use dataplicity. Dataplicity is an open source tool which gives you remote control of your Pi from anywhere. So in this block, we will discuss the installation steps of dataplicity tool

Step 1: Visit the dataplicity official website and enter your email address to get the installation code as

raspberry pi cloud server

Step 2: Just copy and paste the URL into the terminal and start the installation of the dataplicty into your raspberry pi

Step 3: After the installation is completed, verify the email address and after that, you can login into your Pi using the email id and password you have provided.

Step 4: Now you can see that your Raspberry Pi will available for remote access as

raspberry pi cloud server

Step 5: Now click on the Raspberry Pi icon and you can see that there will be a link know as Wormhole by dataplicity, just copy this link and paste into your browser/nextcloud i.e (link/nextcloud) as

raspberry pi cloud server

Step 6: Now you will be redirected to nextcloud login page, enter your valid credentials and you will be logged in to nextcloud account.

raspberry pi cloud server

7. Connecting an External Hard Disk Drive(HDD)

In this step, we will know how to connect an External Hard disk with our Nextcloud server so that we can access it from anywhere

Step 1: first, login to your Nextcloud server using your username and password

Step 2: after a successful login, navigate to right upper corner of the page and click on apps

raspberry pi cloud server

Step 3: Now, you can find External storage support by pressing Ctrl+F and then enable it by clicking on enable, if asked for the password, enter your Nextcloud’s account password

raspberry pi cloud server

Step 4: Now again hover to your profile in upper right corner, click on setting. in the left side of the administration section, there will be an option of External storages, click on that

raspberry pi cloud server

Step 5: in this step, Enter the Folder name anything you want and select External storage local

raspberry pi cloud server

Step 6: Now we have to enter the location of our External Hard disk, for that SSH into your Raspberry pi by the following command (replace credentials with your own)

ssh [email protected]

Step 7: Now change your working directory to root(/) by the following command

cd /

Step 9: after that, create a new folder by any name you want. I’ll use NAS_Server as the name of the folder. type the following command to create a new folder

sudo mkdir NAS_Server

Step 10: Now connect your External Hard disk with Raspberry Pi and type lsblk to show all the connected drives with your Pi. In my case, my External Hard disk has the mount point /sda1 as

raspberry pi cloud server

Step 11: Then type the following command to mount our External Hard disk to the location we created in step 9, for that enter the following command

sudo mount /dev/sda1 /NAS_Server

Step 12: Now head towards step 5, in that we need to proceed further. In location box, type the location of your Hard disk as /NAS_Server

so in brief, all the settings will be as follows

folder name – MY HDD

External storage – Local

Authentication – none

Configuration – /NAS_Server

Available for – select all users or you can also customize accordingly

and then click on save

raspberry pi cloud server

Step 13: and now your External Hard Disk will be visible into the home page of Nextcloud as

raspberry pi cloud server

So now you have created your Personal Cloud Storage, and this will work as a cloud service Like Google Drive, Dropbox, etc. If you are facing any problem, then feel free to ping me here. Please give you valuable feedback in the comment section.


Rajesh Ranjan

I'm a tech enthusiast currently pursuing B.Tech in Computer Science & Engineering. trying to make things as simple as possible

Leave a Reply