Simple Nextcloud Installation on Raspberry Pi

This article explains how to install Nextcloud on the Raspberry Pi. It has been tested with the latest version of Nextcloud (20.1 at the time of writing), but should work for future versions too.  It has also been successfully tested on the latest Pi hardware, the Raspberry Pi 4, and on earlier Pi versions, and on the latest OS, Raspbian/Raspberry Pi OS 10 “Buster”.  Article last updated 21/6/2021.

Nextcloud is an open source software package providing remote file sharing services, similar to Dropbox. But with Nextcloud, you retain ownership, security and control of the shared data. Nextcloud works well on a Pi 2, Pi 3 and especially a Pi 4 but will run very slowly on a Pi 1.

Note: This is a manual, step-by-step procedure. If you would rather do the installation automatically, please see my recent article Automatic Nextcloud Installation on Raspberry Pi, which explains how to install Nextcloud with 3 commands. It is the quickest and easiest way to get Nextcloud running. Both procedures achieve the same overall result, however.

My Raspberry Pi 4 was purchased from The Pi Hut in July 2019. It was installed with Raspberry Pi OS (Raspbian) 10 “Buster” by applying the image “2021-05-07-raspios-buster-armhf-lite.zip” downloaded from the raspberrypi.org downloads page.

Install Apache Web Server

Log into your Pi, either directly or through ssh from another system. I am using ssh. Update the software sources as follows.

$ sudo apt-get update

Install the Apache web server:

$ sudo apt-get install apache2

When asked if you want to continue, type “y” for “yes”. Apache will be installed along with a number of other packages.

In a browser, surf to the IP address of your Raspberry Pi. If you see a page entitled “Apache 2 Debian Default Page”, then Apache is running correctly on the Raspberry Pi. For example, my Pi is using IP address 192.168.1.99. So I start a browser on my PC and surf to http://192.168.1.99/. Alternatively, if you are using the Pi’s graphical desktop, you could start a browser directly on the Pi, eg. Chromium or Netsurf.

Install PHP and Associated Packages

A few packages will now be installed, including the latest version of PHP (7.3 at the time of writing).

Issue the following command. We will use the “-y” switch this time, which answers the “yes/no” question automatically.

$ sudo apt-get -y install php php-gd sqlite php-sqlite3 php-curl php-zip php-xml php-mbstring libapache2-mod-php

The software will be installed, which takes a few minutes.

Restart Apache

Restart the web server now with:

$ sudo systemctl restart apache2

The command restarts Apache, but does not print out any messages.

Download Nextcloud

Okay, the system is ready for Nextcloud to be installed. Download the latest version of the software as follows.

$ wget https://download.nextcloud.com/server/releases/latest.zip

Unpack Nextcloud

Now move the Nextcloud package into place and unpack it:

$ sudo mv latest.zip /var/www/html
$ cd /var/www/html
$ sudo unzip -q latest.zip

Unzipping takes a minute or two.

If you are curious, the version can be be checked with:

$ grep VersionString nextcloud/version.php
$OC_VersionString = '21.0.2';

At the time of writing, (June 2021), the latest version is 21.0.2. To check the latest version online, have a look at the Nextcloud download page.

Create the Data Directory

You must create a “data” folder for Nextcloud and set permissions. Proceed as follows.

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

Check the new directory with ls. You should see output like this, although of course your date and time will be different:

$ ls -ld /var/nextcloud/data
drwxr-x--- 2 www-data www-data 4096 May 27 18:45 /var/nextcloud/data

Set Directory Owners

Next, set the correct ownerships on Nextcloud “config” and “apps” directories:

$ cd /var/www/html/nextcloud
$ sudo chown www-data:www-data config apps

Configure Nextcloud for SQLite or MySQL

Nextcloud can use two kinds of databases: SQLite or MySQL. For a simple installation, with only one or two users, I would recommend SQLite, especially if you are using a P 2 or a Pi 3. It is more light weight and uses fewer resources than MySQL, and is therefore a good choice on Raspberry Pi hardware. To use SQLite, skip straight to the section below entitled “Configure Nextcloud”.

On the other hand, if you want to use MySQL instead, proceed to Install and Configure MySQL Database.  MySQL is an appropriate choice for larger installations, if you plan to have more users, and particularly if you are using a Raspberry Pi 4.

Install and Configure MySQL Database

In order to use the MySQL database (also known as MariaDB), install it now, along with an extra php package:

$ sudo apt-get install -y mariadb-server python-mysqldb php-mysql

Set the MySQL root password and secure the database installation. Run the script /usr/bin/mysql_secure_installation. It will first ask you to enter the “current password for root”. No password has been set yet, so just press return to log in. Next, it asks if you want to set a root password. Answer “y“, choose a sensible password and make a note of it. Then answer “y” to all of the remaining questions, as below.

$ sudo /usr/bin/mysql_secure_installation
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
...
Thanks for using MariaDB!

Next, create a database for Nextcloud, and a database user. In the example I have called the Nextcloud user “ncuser” with a password of “raindrop”. For your own installation, choose a different user name and password. Don’t forget to take a note of both. Note that when running the following command, you will be asked to enter the root password that was set just above.

$ sudo mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 57
Server version: 10.3.29-MariaDB-0+deb10u1 Raspbian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database nextcloud;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> create user ncuser;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> set password for ncuser = password("raindrop");
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all PRIVILEGES on nextcloud.* to ncuser@localhost identified by 'raindrop';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> exit
Bye

Restart the Apache web server once more with:

$ sudo systemctl restart apache2

The command restarts Apache, but does not print out any messages.


Configure Nextcloud

It is time to configure Nextcloud, either to use SQLite as a database, or, if you performed the commands in the last section, MySQL. Either way, proceed as follows.

In a browser, surf to your new Nextcloud web page. Use the URL:
http://your Pis IP address/nextcloud

For example, the address of my Pi is 192.168.1.99. So I go the the URL: http://192.168.1.99/nextcloud

You should see a mostly blue login page. In the middle is a “Performance Warning” about SQLite. Ignore that. Near the top it says “Create an admin account”. Think of a user name and password and type them into the boxes provided. Then click on the “Storage and Database” drop-down. In the “data folder” box which appears, delete what is already there and replace it with “/var/nextcloud/data

If you want to use SQLite as the database, then click on the “Finish Setup” button near the bottom of the page. Wait for a couple of minutes while Nextcloud completes the installation. During this time, Nextcloud creates more files and directories in our data directory, and it puts a SQLite database in there too.

If you want to use MySQL as the database, then where it says “Configure the database”, click on the button marked “MySQL/MariaDB”. Four new fields appear. Complete them as follows.
– for the database user, enter the name of the MySQL user you created above (“ncuser” in the example).
– for the database password, enter the accompanying password (“raindrop” in the example).
– for the database name, enter “nextcloud”
– leave “localhost” as “localhost”.

– then click on the “Finish Setup” button near the bottom of the page. Wait for a couple of minutes while Nextcloud completes the installation. During this time, Nextcloud creates more files and directories in our data directory, and it populates the MySQL database.

Completing the Configuration

While the installation runs, a dark blue “Recommended apps” box will appear, and a few Nextcloud add-ons are installed.  It takes a few minutes, so be patient.

A few minutes later,  you should see the Nextcloud intro page with the legend “Nextcloud Hub”.  Click the right arrow to read more, or click the cross at the top right of the dialogue to dismiss it. You should now be looking at the main Nextcloud page. There you can see a few widgets, such as “Recommended files” and “Talk mentions”.

Congratulations!  You have successfully installed Nextcloud!


Storing Nextcloud Data on a Separate Disk (Optional)

If you have a USB disk or thumb drive, you can use it to store the Nextcloud Data. In doing so, you might obtain more capacity for your data and/or improved performance.

First, mount your disk at a suitable location on the pi. Then proceed as follows. In this example, a thumb drive is mounted at “/disk1”. Move the Nextcloud data folder onto the drive as follows.

$ sudo mv /var/nextcloud/data /disk1/data
$ sudo ln -s /disk1/data /var/nextcloud/data

The first command moves the data. The second creates a link from the original data location to the new one. Finally, if you have Nextcloud open in a browser, refresh the page. It should reappear after a few moments. Your data has now been moved onto the disk/thumb drive. Try dragging a large file into Nextcloud – you should see the disk access light flash as the data is written.

Securing the Site with TLS/HTTPS

If you want to secure your Nextcloud installation by converting it from HTTP to HTTPS, see my later article: How to Convert a Website from HTTP to HTTPS.

Conclusion

That is the end of the procedure for installing Nextcloud. Your Nextcloud installation should now be fully working. I hope this guide was easy to follow and not too long or fiddly.

Note: Prior to January 2018, this article included a section on moving the Nextcloud data directory for security purposes. It is no longer necessary. Alterations to the procedure above mean that the data directory is created at a secure location and does not need to be moved.

Note: In the past, this article also included a section explaining how to increase the Nextcloud file size upload limit. This is no longer needed, as recent Nextcloud versions no longer have the old file size limitation.

Appendix – A Note on Nextcloud vs Owncloud

Nextcloud was forked from ownCloud in June 2016. Since then, Nextcloud has increased in popularity and has become, for many users, the natural successor to ownCloud. Previously I wrote an article describing how to install and upgrade Owncloud. Now, I would recommend Nextcloud over ownCloud, except for large corporate users who might already have commercial agreements with ownCloud Inc. If you came here from the ownCloud article, thank you for your patience.

END.

174 thoughts on “Simple Nextcloud Installation on Raspberry Pi

  1. Thanks for your superb tutorial!

    Everything went great except at the end. The server is running well except that it doesn’t let me upload files.
    Everytime I try to upload one it just displays a ‘Forbidden’ message.
    Do you know where that could come from?

    Thanks for your help!
    Leo

    • Hi Leo

      It sounds like it might be a permissions problem. Did you set the permissions properly on the “data” directory? What was the full error message that you saw ?

      Jim.

  2. Hi, i appreciate your guide, this was the first one that helped with setting up MySQL DB on a Raspberry Pi.

    I am having issues though, with the permissions you’ve given to apps and config folder using “sudo chown www-data:www-data config apps” – The inbuilt browser based updater fails. I used “sudo chown -R www-data:www-data /var/www/html/nextcloud/” to overcome this issue. It worked perfectly.

    However after moving my data folder to external drive, it is not working. There isn’t an HTTP error code but an error page stating internal server error.

    I’ve pasted the error here – https://pastebin.com/RnbTiSQZ

    Could you kindly help me out?

    • I tried with “sudo chown -R www-data:www-data /var/www/html/nextcloud/”

      Any particular reason (security?) that you’re giving permission only to two directories instead of entire /nextcloud* folder and subfolders?

      • Hi Parth. Only the “apps” and “config” folder need those permissions in order for Nextcloud to work properly (with the possible exception of the inbuilt updater, as mentioned in your last comment). My own Nextcloud installation is running just fine with those permissions. Meanwhile, in the interests of security, it is generally important not to loosen permissions more then necessary, especially on an internet-facing system, like a Nextcloud server. Cheers, Jim.

    • Hi Parth and sorry for the lateness of this reply. The procedure is not designed to support the inbuilt browser updater. If you need to upgrade Nextcloud, I would recommend saving all of your files, then doing a fresh install of the latest version of Nextcloud, then putting the files back.

      You made the inbuilt updater work by changing the file permissions. In that case, I would recommend changing the file permissions back immediately after the upgrade.

      The last point you mention is that Nextcloud fails after the data was moved. I am not sure how the data move was done, but judging from the error message, Nextcloud is looking for files (eg. its log file) and not finding them where it expected. It is important that great case it taken when moving Nextcloud data files. At this stage, I would recommend saving off all of your data files, doing a fresh Nextcloud install, and then putting the files back.

  3. I’ve come back to my RPi to install some updates (which took a long time), and realised that it has been running in the background for almost a year, in daily use by some other computers, with no attention required whatsoever. Thanks again Jim.

    • Cheers Greg, glad to hear it is still running. You might be interested to install Nextcloud 16, which has recently come out.

      Jim.

  4. Thanks so much for the instruction. works perfectly. I am new to everything and I have been trying to install nextcloud to the dusty Raspberry Pi3 from my husband, I’ve followed 3 or 4 different instructions closely and I could’t get nextcloud up and running, so packages versions is so confusing and most software update so much and so quick and make so instructions outdated. All told just thank you for putting up this instruction.

    • Hi Sue, sorry about the lateness of this reply which is due to illness. The software packages required for Nextcloud can indeed be confusing, especially with different versions of Raspbian. Glad to hear you got it all working.

      Cheers,
      Jim

  5. Hi,
    Thanks a lot for this tutorial!

    I am stuck on the first installation web page where i have to configure the admin user and db settings. For some reason im not aware of the page is always waitting to the instalation process ends, but it does not ends. Ive checked and seems we have tables created on mysql and the data directory has two files. But the files are empty.

    Ive installed on a fresh raspbian image on pi 4. Two times now and the result is the same. Also tried to configure manually or automatically with your ansible script but with same result.

    Help please!

    • Hi Reis, sorry for the lateness of this reply which was due to illness.

      You have followed the instructions, and at the last stage (the section entitled “Configure Nextcloud” above), you click the “Finish Setup” button and nothing happens? Is that correct?

      It should finish configuring in about 2 minutes or less. I am not sure what has happened in your case. Did you select SQLite or MySQL as the database ?

      Cheers,
      Jim

  6. Hi,

    I’ve followed you method on a raspberry Pi 4 and it works great.
    Thanks for this description step by step.
    It helped me a lot and i understand now better some details with mysql and the mounting of an external disk.
    I’ve got just one notice about the step to give all the rights to the database’s owner. It was wrong for me. The message told me that this command line couldn’t find the user even it was in the table.
    So after a little search on the web it was due by the length of my password.
    After i’ve reduce it, everything works fine.

    Thanks again for this really clear procedure.

    • Hi Sébastien, glad it worked for you, and that you were able to find and fix a bug to do with password length. I haven’t seen that situation myself.

      Cheers again,
      Jim.

  7. Nextcloud works with Raspberry pi 4 on the sd card, but I have a problem with transferring data to a USB drive. After executing the commands from the description, the files and shortcuts appear in the appropriate directories. Refreshing the application in the browser returns an error – Internal Server Error. The server encountered an internal error and was unable to complete your request.

    Sorry for my bad English 🙂

    • Hi dariuss. Your English is good. As I understand it, you are following the section of the article entitled “Storing Nextcloud Data on a Separate Disk”. You execute the two commands shown (mv and ln). But when you refresh the web page, it gives a message about a server error (“Internal Server Error. The server encountered an internal error and was unable to complete your request”).

      This seems to indicate that the data was not moved properly. One of the two commands (mv or ln) probably did not work properly. Please check and try again.

      Cheers,
      Jim.

  8. Hi, thanks for a great article. Excellent, really. Successful in installing nextcloud but when I went to the last step to “move” the data over to my attached usb disk, i get this error and the web page no longer displays – it did work before this last change but now it says “internal server error”.
    I did this:
    1. sudo mount /dev/sda2 /mnt/mydisk
    2. ls /mnt/mydisk – displays directory structure on usb disk
    3. sudo mv /var/nextcloud/data /mnt/mydisk/data
    4. sudo ln -s /mnt/mydisk/data /var/nextcloud/data
    ln: failed to create symbolic link ‘/var/nextcloud/data’:
    File exists
    I think I know how I messed up. Mistakenly I typed in the wrong command – mis-named my file name structure before performing the last step.
    Right before step 4, I mistakenly typed this (note syntax errors) sudo ln -s /disk1/data /var/nextcloud/data
    That command was accepted w/o error, so I believe I may need to “unlink” before I can get the correct command to be accepted. Make sense – I hope?
    Thanks very much –
    Bill

    • Hi Bill, cheers. It sounds like a link was accidentally created. The second “ln” (the correct one) fails because there is already a link there, and it can’t create one link on top of another.

      Remove the erroneous link with “rm /var/nextcloud/data”, then repeat your step 4 – it should work this time.

      Cheers,
      Jim.

      • Yep, that’s what I was thinking – just didn’t know the remove command. Still Learning. Hey, thank you very much for taking the time to support this.
        Cheers,
        Bill

      • Had to get to work this morning, but I followed your instructions just now, and of course, it works – or at least after removing the link and rerunning my #4, – no errors this time. I can connect to the web page again, although it complains about permissions – see below.
        I thought I maybe read someone’s post last night where he had this same error, but running out the door to bible study. Thanks a million. I’ll try to figure it out later…or if you know, by all means, please share. Thank you very much – again.

        “Error
        Your data directory is readable by other users
        Please change the permissions to 0770 so that the directory cannot be listed by other users.”

        Regards,
        Bill

        • Hi Bill, the directory permissions should have been set when you executed the command “sudo chmod 750 /var/nextcloud/data”, earlier in the procedure, under the section entitled “Create the Data Directory”. Did that get missed out?

          • Hi, I went back and looked in my terminal and I see I did/have issued these commands: sudo mkdir -p /var/nextcloud/data

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

            sudo chmod 750 /var/nextcloud/data

            ls -ld /var/nextcloud/data
            drwxr-x— 2 www-data www-data 4096 Jan 26 19:28 /var/nextcloud/data

            Thank you again – appreciate it.
            Bill

          • Hi Bill, the permissions on your data directory are 0750, but Nextcloud is giving an error message saying that they are 0770, which is incorrect. I am not sure why this would be. Without actually being there, it is difficult to say why this error message is appearing.

            Cheers, Jim

  9. Hi Jim,
    Thanks for writing this great article. It is very clear and well written. I’m a newbie with Linux… actually I used it in when I went to engineering school but that was a lifetime ago. I’m also newbie with raspberry pie and I didn’t even know these existed until last month. The only reason I discovered raspberry pie was because I’m nearly out of storage space on my various cloud accounts (one drive = 5GB, Samsung cloud for phone = 15GB and I used up 10 GB already) so I started researching “personal cloud” and did a lot of reading on NAS devices like the Synology DiskStation, WD Ex2 Ultra, etc…) but the cost was higher than what I wanted to spend. Then I discovered Raspberry Pie, Owncloud and NextCloud and found out how much they cost and ended up here! I attempted other “how to” procedures but it never worked out until I tried yours! Now I have a cost-effective personal cloud.
    Unfortunately, I ran into the same problems other users have written about with moving the data to an attached USB. I get internal errors and the “please change the permissions to 0770 so that the directory cannot be listed by other users” but found a way to fix it! (Hint: umask)
    I still work as a design engineer so my mindset was to test the system and simulate various scenarios before I commit transferring my data to this new system. I would intentionally pull the plug on the RPi to simulate a power outage or I would intentionally pull the usb stick to simulate the kids and pets running around and knocking things over. I didn’t modify any configuration files to automount the storage drives so I know that I would have to re-mount the storage drives and then I ran into the problems. So, I did more research and learning into Linux commands and file structure etc. The solution that worked for me so far is to include umask when mounting the storage drive and making sure all the permissions were the same as before the “power outage”. This is what worked for me:
    sudo mount -o umask=027,uid=www-data,gid=www-data /dev/sda1 /disk1
    I noticed that after mounting the usb storage I wasn’t able to change permissions or ownership of the usb storage. The permissions and ownership are set during mounting and can’t be changed after it’s mounted. I still have more to learn with Linux commands and some more testing before I commit to data transfer but I wanted to share this with you and any others going thru the same.

    Thanks,
    Dan

    • Hi Dan. You have come across some permissions issues and solved them with a umask on the mount command. Thanks for coming back with this information, which will hopefully be useful to other readers.

      Permissions on mounted file systems is quite a large and involved subject in Linux. When one file system is mounted on another, file permissions can be affected by a number of variables. Sometimes these factors combine, which can lead to quite a complicated situation.

      Factors affecting the permissions on a mounted file system include: the file system type (eg. ext4, NTFS, vfat), permissions on the mount point, umask of writing processes, mount options, file ownerships and so on. People reading this article are likely to be using different kinds of file systems and hardware, mounted in different ways. Eg. one person might be using a thumb drive formatted as vfat, while another user is storing his data on a powered USB disk containing an EXT4 file system.

      It is therefore difficult to give a recipe that works for all, and the article does not address these issues in detail. (Incidentally, there are many Internet resources that do).

      One recommendation I would make, and might add to the procedure, is to use EXT4 on your external disk. EXT is native to Linux an the Pi, and using it for the auxiliary storage is likely to avoid many permissions complications.

      Cheers,
      Jim

  10. Hello:
    Thanks for posting such a nicely detailed article. I just got a Pi4 and will do the install on it. One suggestion, would you please make a note somewhere at the beginning of the article when the procedure was last updated? and the current versions of Raspian and Next cloud combinations are recommended?
    Because things move so fast in the Linux and nextcloud world with version releases, It would be nice to know how far one is from the base line configs or the baseline + updates you did, when you read this article ‘in the future’. May be helpful in tracking down reasons for certain types of errors.
    Thank you!
    J

  11. Hi there, hope things are going well for you in these crazy times. I was wondering if you could assist me with enabling “pretty URLs” as shown here: https://docs.nextcloud.com/server/18/admin_manual/installation/source_installation.html

    When I enter the following command, I get the following error:
    sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess
    Error updating .htaccess file, not enough permissions or “overwrite.cli.url” set to an invalid URL?

    I am not entirely certain which .htaccess file this is referring to and what additional permissions are being requested. The results of this find command may help:

    sudo find / -name .htaccess
    find: ‘/proc/19026/task/19026/net’: Invalid argument
    find: ‘/proc/19026/net’: Invalid argument
    /home/emilio/nextcloud/config/.htaccess
    /home/emilio/nextcloud/.htaccess
    /var/nextcloud/data/.htaccess
    /var/www/nextcloud/config/.htaccess
    /var/www/nextcloud/.htaccess

    • Hi Emilio, thanks. Like many people I am at home, sitting out the virus. The best of health to you.

      Regarding your question, it is an issue better directed to Nextcloud support or forums. I can answer questions the above article only. I don’t provide general support for the Nextcloud product. I have never used the occ command and can’t advise in this instance. Sorry not to provide a more helpful answer.

      Jim.

      • No apologies necessary. Thank you for taking the time to write the article in the first place and for getting back to me. Be safe!

  12. Hi,

    Great Tutorials. I have followed exactly how it is mentioned on the tutorial. Everything went smoothly until transfer DATA to external HD.
    this is what I have done for move :
    sudo mv /var/nextcloud/data /media/pi/Babu-Documents/nextcloud/data
    sudo ln -s /media/pi/Babu-Documents/nextcloud/data /var/nextcloud/data

    From the Browser it is mentioned below :
    “Your data directory is invalid Ensure there is a file called “.ocdata” in the root of the data directory.”

    I have notice file permission has been changed after created the symlink.

    Previously it was :
    pi@raspberrypi:~ $ sudo ls -la /var/nextcloud/data/
    total 68
    drwxr-x— 5 www-data www-data 4096 Apr 28 14:36 .
    drwxr-xr-x 3 root root 4096 Apr 28 13:44 ..
    drwxr-xr-x 9 www-data www-data 4096 Apr 28 14:38 appdata_octt2r8bik26
    drwxr-xr-x 2 www-data www-data 4096 Apr 28 14:36 files_external
    -rw-r–r– 1 www-data www-data 542 Apr 28 14:34 .htaccess
    -rw-r–r– 1 www-data www-data 0 Apr 28 14:34 index.html
    -rw-r—– 1 www-data www-data 38769 Apr 28 14:41 nextcloud.log
    -rw-r–r– 1 www-data www-data 0 Apr 28 14:34 .ocdata

    After the link create or move :
    pi@raspberrypi:~ $ sudo ls -la /var/nextcloud/data/
    total 45
    drwxrwxrwx 1 root root 464 Apr 28 14:36 .
    drwxrwxrwx 1 root root 144 Apr 28 14:45 ..
    drwxrwxrwx 1 root root 424 Apr 28 14:38 appdata_octt2r8bik26
    drwxrwxrwx 1 root root 0 Apr 28 14:36 files_external
    -rwxrwxrwx 1 root root 542 Apr 28 14:34 .htaccess
    -rwxrwxrwx 1 root root 0 Apr 28 14:34 index.html
    -rwxrwxrwx 1 root root 42941 Apr 28 14:45 nextcloud.log
    -rwxrwxrwx 1 root root 0 Apr 28 14:34 .ocdata

    Also on External HDD :
    pi@raspberrypi:~ $ ls -la /media/pi/Babu-Documents/nextcloud/data
    total 45
    drwxrwxrwx 1 root root 464 Apr 28 14:36 .
    drwxrwxrwx 1 root root 144 Apr 28 14:45 ..
    drwxrwxrwx 1 root root 424 Apr 28 14:38 appdata_octt2r8bik26
    drwxrwxrwx 1 root root 0 Apr 28 14:36 files_external
    -rwxrwxrwx 1 root root 542 Apr 28 14:34 .htaccess
    -rwxrwxrwx 1 root root 0 Apr 28 14:34 index.html
    -rwxrwxrwx 1 root root 42941 Apr 28 14:45 nextcloud.log
    -rwxrwxrwx 1 root root 0 Apr 28 14:34 .ocdata

    I guess I am missing the file permission. Please help on this.

    Thanks in advanced.

    • Hi Sarif,

      It looks as if the ownerships and permissions of your data files changed when you moved them onto external media. The folder “.ocdata” is now owned by root, so Nextcloud can’t read it and hence the error message.

      This has most likely happened because your external disk does not contain a Linux native file system such as EXT4 or XFS, or it may be located on a NAS or other network share. Sometimes, other file systems cannot honour Linux file system permissions. I would recommend using a disk formatted as EXT4 or XFS. (Note that formatting removes all data from a disk, so take care).

      Cheers,
      Jim.

      • Thanks Jim for your great response. I will try to use linux native file system as my current HD is NTFS. I will come back to you soon.

        /Sharif

      • Hi Jim,
        Still its not working, after changing to ext4.
        But I found someone mentioned to go in maintenance mode or stop apache first. Could you please comment on below steps :

        1. sudo -u www-data php /path/to/nextcloud/occ maintenance:mode –on
        2. mkdir -p /new/path/to/data
        3. cp -a /path/to/data/. /new/path/to/data
        4. mv /path/to/data /path/to/dataBackup
        5. ln -s /new/path/to/data /path/to/data
        6. chown -h www-data:www-data /path/to/data # To set symlink ownership
        7. chown -R www-data:www-data /new/path/to/data # To set actual data dir ownership
        8. sudo -u www-data php /path/to/nextcloud/occ maintenance:mode –off

        Best Regards
        Sharif

        • Hi Sharif,
          I can only help with the procedure in the article. Unfortunately I can’t troubleshoot solutions provided by other people. In this case, I am not familiar with the occ command and cannot advise on it use.

          The procedure in the main article should work, and the part entitled “Storing Nextcloud Data on a Separate Disk” has been tested and works, for example with USB thumb drives or external disks formatted appropriately. Sorry I can’t provide further information.

          Jim.

          • Thanks Jim. I understand. Just one clarification, from your article, if I dont move data dirctory to the external storage, what problem I can face ?

            BEst Regards
            Sharif

          • Hi Sharif, moving the data is optional. There is no problem at all with leaving it where it is. Some people move the data because they need more capacity, that’s all. Cheers, Jim.

  13. Hi, I just want to ask about the last section of the passage.
    Will the hard link created by the command “ln -s” automatically transfer files from var/www/html/nextcloud/data to the external drive? I am just afraid of filling my operation system disk with data
    Thanks

    • Hi H,
      I assume you are referring to the section entitled “Storing Nextcloud Data on a Separate Disk (Optional)”.

      It is the “mv” command that moves the data. The “ln -s” command does not move data, it just creates a link.

      Jim

  14. Thank you for this article. I have installed Nextcloud on two of my Raspberry Pis with your method. It works perfectly. I installed Nextcloud in LXD container (Ubuntu) in one RPi.

  15. TASK [Create MySQL admin user] *************************************************
    An exception occurred during task execution. To see the full traceback, use -vvv. The error was: InvalidPrivsError: unable to parse the MySQL grant string…

    PLAY RECAP *********************************************************************
    localhost : ok=5 changed=0 unreachable=0 failed=1

    What happend?

    • Hi Dmitry

      I have shortened the message above and removed the additional comment re traceback. Your comments do not appear to be related to the above article. The transcript seems to be an Ansible output, but there is no Ansible in this procedure.

      You might have been thinking of my other procedure, automatic nextcloud installation on-raspberry pi. If so, place any relevant comments under that article.

      Thanks,
      Jim

  16. Such a pleasure to follow your intelligent, well structured article. Installation was painless and I’ve been running NextCloud happily on my RPi 4 for a month or so now. Thank you so much.

  17. Hi, thanks for the hard work of writing all this helpful article.
    I have been happily running a Nextcloud-Raspbian Buster on a Pi3 for several years, and am now running into issues with the News app, not supporting 32bits anymore in future updates.
    It seems to me that you have installed a 32bit version of Raspbian on your Pi4, is it correct?
    I am looking around before buying the Raspi4, and getting a RAM and USB3 upgrade, but I am a bit worried by the unavailability of a release version of Raspbian 64bits…
    Do you have an opinion about running Ubuntu Server instead?
    Additional question: would getting the max RAM be useful in the case of a web server?
    Thanks again 🙂

    • Hi Shvia. In the case of a web server, small RAM is enough if you are just serving a few web pages or running (say) Nextcloud for your own use. Serving standard web pages is not memory intensive. If on the other hand, you were setting up some bit web application for many many users, consider getting more memory.

      I’ve not tried Ubuntu server. Raspbian OS works fine for all my applications. If you want a 64 bit version of Raspbian OS, there is an experimental/beta version under development I think (eg. see https://www.raspberrypi.org/forums/viewtopic.php?t=292965). 32 bit works fine for me.

      Cheers,
      Jim

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.