Setup a Raspberry Pi Cloud Server With Nextcloud

Mapping Nextcloud to the USB drive

At the moment Nextdrive is depositing files sent to it to the default location on the SD card.

Now that our USB drive is setup we can change this so that files are stored on the external hard disk.

The first step is to create a folder for the data:

sudo mkdir -p /mnt/data/nextcloud

The next step is to move the data already held in the Nextcloud folder to our new folder:

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

Now it’s time to change the Nextcloud config so that it points to our new folder. The first step is to change to the nextcloud configuration directory:

cd /var/www/html/nextcloud/config

It’s worthwhile backing up the config file just in case something goes wrong:

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

Next open the config file with nano:

sudo nano config.php

We need to change the existing datadirectory line to one that meets our new setup, so:

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

Becomes:

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

Press ctrl+O to save, then ctrl+x to exit

Changing File Size Limits

Nextcloud has some fairly strange ideas about file sizes for cloud servers, so we need to increase the default file sizes.

To do this we need to edit another config file:

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

You’ll need to find the following two lines and ammend them with greater file size values:

post_max_size = 8M
upload_max_filesize = 2M

I recommend 1024M for each.

Presss ctrl+O to save, then ctrl+X to exit nano.

Now you need to restart Apache for the changes to take effect:

sudo service apache2 restart

2 thoughts on “Setup a Raspberry Pi Cloud Server With Nextcloud”

  1. Matt, thanks for the very complete and useful guide. Yours is the best one I’ve found when looking for help with installing nextcloud on my local server.

Leave a Reply