Simple Nextcloud Installation on Raspberry Pi

*UPDATED November 2017 for Raspbian Stretch*. The Raspberry Pi’s low power consumption makes it well suited to the role of always-on web server. This post describes how to install Nextcloud onto the Pi.  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 and Pi 3 but will run very slowly on a Pi 1.

The below procedure describes how to install Nextcloud version 12.0.0, the latest stable version at the time of writing (27th May 2017), but it should work for later/future versions too.

NOTE: Nextcloud was forked from ownCloud in June 2016. It now seems that Nextcloud has largely taken over ownCloud’s role, 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 have come here from the ownCloud article, thank you for your patience. Okay, back to the procedure…

My Raspberry Pi 2 was purchased from RS Components in the UK. It was installed with Raspbian “Stretch” (Debian 9) by applying the image “2017-09-07-raspbian-stretch” downloaded from the downloads page. Raspbian Stretch was launched in August 2017, to supercede the earlier Raspbian “Jessie” (Debian 8). The following procedure works on both versions. Where there are differences, instructions applying to the both versions are provided. (Actually there is only one difference, relating to PHP packages)

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 So I start a browser on my PC and surf to Alternatively, if you are using the Pi’s graphical desktop, you could start a browser directly on the Pi, eg. Netsurf.

Install PHP and Associated Packages

A few packages will now be installed. On Raspbian Jessie, install PHP 5. On Raspbian Stretch, install PHP 7 instead. If you are not sure what version of Raspbian you are using, check the contents of the file /etc/os-release. Here, I am using Stretch:

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"

The version of Raspbian is clearly shown on the first line of the file.

Install PHP 7.0 and Associated Packages (Raspbian Stretch only)

On Raspbian Stretch, Nextcloud requires PHP 7 and few other packages. Install them as follows. We will use the “-y” switch this time, which answers the “yes/no” question automatically.

$ sudo apt-get -y install php7.0
$ sudo apt-get -y php7.0-gd
$ sudo apt-get -y sqlite
$ sudo apt-get -y php7.0-sqlite3
$ sudo apt-get -y php7.0-curl
$ sudo apt-get -y php7.0-zip
$ sudo apt-get -y php7.0-xml
$ sudo apt-get -y php7.0-mbstring

Install PHP 5 and Associated Packages (Raspbian Jessie only)

On Raspbian Jessie, Nextcloud requires PHP 5 and few other packages. Install them as follows.
$ sudo apt-get -y install php5
$ sudo apt-get -y install php5-gd
$ sudo apt-get -y install sqlite
$ sudo apt-get -y install php5-sqlite
$ sudo apt-get -y install php5-curl

The software will be installed, along with other dependent packages.

Restart Apache

Restart the web server now with:

$ sudo service apache2 restart

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

Install Nextcloud

Okay, the system is ready for Nextcloud to be installed.

Surf to the Nextcloud download page.  At the top left is a section entitled “Get Nextcloud Server”.  Click in the “Download” button just below that.  A popup window opens.  Click on the big blue “Download Nextcloud” button.  Download the .zip file. Then copy it to the Raspberry Pi.

Alternatively (quicker), get the file on one step with this command on your Pi:

$ wget

At the time of writing (17th Nov 2017), the latest version of Nextcloud is 12.0.3. The version, and the link to download it, might have changed by the time you read this article. If so, just change the link accordingly (check it at the download page above.  For example in Firefox, right-click the big blue download button and select “Copy Link Location”.  Then just paste the link into a wget command, as above).

Now move the Nextcloud package into place and unpack it:

$ sudo mv /var/www/html
$ cd /var/www/html
$ sudo unzip -q

Tip: if you are new to Linux. in case you were not aware, the tab key can be used to automatically enter file names, which saves on typing.  For example, to enter the last command, I could have just typed “sudo unzip -q next” and pressed the tab key.  In fact I did.  The whole file name is then inserted automatically.

Create the Data Directory

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

$ sudo mkdir -p /var/www/html/nextcloud/data
$ sudo chown www-data:www-data /var/www/html/nextcloud/data
$ sudo chmod 750 /var/www/html/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/www/html/nextcloud/data
drwxr-x--- 2 www-data www-data 4096 May 27 18:45 /var/www/html/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

Create a Login for Nextcloud

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

For example, the address of my Pi is So I go the the URL:

You should see a mostly dark 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 “Finish Setup” button.

…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. SQLite is a good choice if your Nextcloud implementation will be small with only a few users. It offers a good balance between speed and reliability. For larger installations, eg. in the enterprise, I would recommend using a MySQL database instead. Using MySQL is beyond the scope of this document.

Hey Presto! After a delay of 2 minutes or so, you should see the Nextcloud intro page with the slogan “a safe home for all your data”. Click the cross at the top right of the dialogue to dismiss it.  You should now be looking at the main Nextcloud “Files” page. There you can see a couple of folders, a Nextcloud MP4 video file, and a PDF Manual.


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.

Below is a procedure for securing the Nextcloud data directory. I highly recommend it, especially if you are planning to make Nextcloud files accessible from the Internet. After that are instructions for increasing the Nextcloud upload limit.

Secure the Nextcloud Data Directory

This section assumes that you have installed Nextcloud by following the above procedure, using SQLite as the chosen database.

It is highly recommended to make Nextcloud more secure by moving the “data” directory to a more secure location.  You might also want to move it for other reasons. For example, you could obtain more speed or capacity by moving the data directory onto a separate disk. Let’s move it to /var/nextcloud/data.  That will prevent any unauthorized users from accidentally gaining access through the web browser.

Move the data directory:
$ sudo mkdir -p /var/nextcloud
$ sudo mv -v /var/www/html/nextcloud/data /var/nextcloud/data

Configure the new data location into Nextcloud.  Using vi or another editor of your choice, edit the configuration file.  Make a backup copy first, just in case there is a mistake with the edit:

$ cd /var/www/html/nextcloud/config
$ sudo cp -p config.php
$ sudo vi config.php

Change this line:

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

to this:

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

Be careful not to delete the comma at the end of the line.  Save the file and exit the editor.

Finally, update the SQLite database to reflect the new storage location. Open the database as follows:

$ sudo sqlite3 /var/nextcloud/data/owncloud.db
SQLite version 2014-10-29 13:59:56
Enter ".help" for usage hints.

Now modify the “oc_storages” table to point to the new data location. Be careful to type this line exactly as shown, including all signs and punctuation marks:

sqlite> update oc_storages set id="local::/var/nextcloud/data/" where id like '%local%';

Quit out of the database. Note the dot before the quit command:
sqlite> .quit

Note: if you type something accidentally, and see this prompt: “ …>“, just type a semicolon (“;”) and press return to get back to the “sqlite>” prompt.

Now, in the browser, refresh the Nextcloud web page.  You should see the same files and folders as before.  That completes the securing of the Nextcloud data. Although it is still owned by www-data user, the Nextcloud data is now outside of the Apache root directory, and is therefore inaccessible to regular web requests.

Increase the Nextcloud Upload File Limit

Note: The following procedure does not seem to be needed in version 12 of Nextcloud. Older versions had a limit of 2MB in the size of file that could be uploaded. The limit seems to have been lifted in version 12, making the following unnecessary. It is left here in case anyone finds it useful, for example, if they are running an older version of Nextcloud.

Upload a file to Nextcloud as follows. Click on the square button containing a plus sign (“+”) near the top of the page. A drop down menu appears. Choose the first menu item, “Upload”, and select a file. The file will be transferred and you should see it appear in the Owncloud list of files. However, if the file was more than 2 MB in size, it will not upload. Instead a message will appear at the top of the screen – “Error uploading file “filename”: Total file size XX MB exceeds upload limit 2 MB”.

By default, the maximum size of file that can be uploaded is 2 MB, which is not enough for many people, Increase it as follows.

Edit the file /etc/php5/apache2/php.ini.  You can use the “vi” editor, or another if you prefer:
$ sudo vi /etc/php5/apache2/php.ini

Change these two lines:
post_max_size = 8M
upload_max_filesize = 2M


post_max_size = 20M
upload_max_filesize = 20M

and save the file. Note: if you are having difficulty finding these settings in the file, use your editor’s search facility.  In vi, you can search by pressing the slash key (“/”), then typing what you are searching for, such as “post_max_size”, then pressing enter.

Restart Apache:
$ sudo service apache2 restart

And refresh your browser page. The upload limit should have increased to 20 megabytes, which you can verify by trying another upload, as above.


80 thoughts on “Simple Nextcloud Installation on Raspberry Pi

  1. Pingback: Simple Owncloud Installation on Raspberry Pi 2 | Unix etc.

  2. this worked great for me thank you for all your time in making this guide. i have a 1tb hard drive connected to my raspberry how do i make next cloud save the files to my hard drive not the sd card? thanks

  3. Hi Cody. All that is needed is to (1) reformat your 1 TB drive and then (2) Move the Nextcloud “data” directory onto it. (WARNING: reformatting the 1 TB drive will destroy any data already existing on the drive).

    For a more detailed guide on this, see the accompanying Owncloud article – scroll down to the section entitled “Move the Owncloud Data Directory (optional)”.

    • Thank you i have everything working great and moved over to my hard drive. Is there a part in the guide where i can log into my nextcloud without being on the nextwork? i have my ports forwarded but i dont know how to go to “” i also have a no-ip for my DNS ip. thanks again your guide was the best guide ive read.

      • Hi Cody. Unfortunately I don’t understand the question about being able to log into Nextcloud “without being on the network”. You should be able to obtain a domain name from no-ip, point it to your IP address and then access Nextcloud by name.

  4. Hi Jim! Thank you for this perfect description to install nextcloud!! Do you know how I can use the usb storage at my pi. I just don’t know how to mount it? Thanks for your answer, Johannes.

  5. Thank you , thank you. Your article represents my fourth attempt at getting a local cloud server up and running on the Rpi. Needless to say , the others failed at some point. Your’s is clear and absent any typos! Grats. Everything went great until… I attempted to access the server from a different computer on the same network ( e.g. the server is at and the other computer is at ). No response from the Rpi. Any suggestions?


      sign up there.
      Setup port forwarding on your home router.
      If your home router supports ddns then you put in your username and password for into your router and it keeps it up to date.

    • Hi Igor, to access Nextcloud from outside your home, 2 steps are needed:

      1. On your modem/router, forward port 80 to the Pi containing Nextcloud.
      2. As Randell says, obtain a domain name from no-ip or another provider. You can access Nextcloud without a domain, simply by surfing to your router’s external IP address. But this IP address changes every few days, so it is more convenient to obtain a domain name.

      Note that there are security implications if you forward the port as in step (1). For more information, see the section entitled “A Note on Security” in my partner article:

  6. Hi,

    Would like to ask if you could also guide me in making nextcloud more secure? I heard that using http (which this guide is using) is not really that secure.

    I also would like to ask how to configure the email notification in nextcloud.

    I also have setup a pi-hole on my pi so not sure if this will conflict anything

  7. Regretably however, at the end of the process after entering username and passwd nextcloud came up with a blank page, what has gone wrong?

    • Hi Debonaire,

      A blank page at the end of the process ? Blank pages can be tricky to diagnose, but they sometimes happen due to PHP errors. Have a look at the apache error log file /var/log/apache2/errors.log.

      Type this show errors at the end of the log:
      tail /var/log/apache2/error.log

      …then try to log in to Nextcloud again, so that the white screen comes up again.

      And repeat the command:
      tail /var/log/apache2/error.log

      Did any new error messages show up ?

      • Wow, many thanks for volunteering help,I amimpressed and grateful. I reinstalled nextcloud and set the data directory to my USB HD. Now the problem is that nextcloud is insuferably slow to come up. It lookslike the USB disk is accessed but just ‘spins’ for minutes before loading the page. I will try to point nextclud back to the sd card datadirectory andseewhathappens.

  8. Pingback: Setting up NextCloud on Raspberry Pi 3 | David R. Wilson

    • Hi David, you report that UBlock Origin interferes with Nextcloud under Chrome. I use UBlock Origin in Firefox, and with that setup, it does not seem to block Nextcloud.

    • Thanks for the suggestion I do not think that I am running UBlock in my laptop’s firefox and I get the same from th eEpiphany browswer on the pi. I think the problem is somewhere in the output of the tail command listed below

    • Hi David. I get the page shown on the link from your blog. When I switch off Ublock Origin in Chromium I still get the same result. I’ve also tried in Safari on Mac and old and new iPads with the same result. Also, when I installed Php5 I got a message suggesting it wasn’t found. Can I use Php7 insread?


  9. Hi Jim,

    As I said above, I pointed nextcloud to the data directory on the sd card! Now I am back to the blank page. Following your instructions I issued the ‘sudo tail /var/log/apache2/error.log’ command. Here is what the command spews out:

    [Sun Feb 05 14:33:05.893221 2017] [:error] [pid 3456] [client]
    PHP Fatal error: Uncaught exception ‘Doctrine\\DBAL\\DBALException’ with message
    ‘Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000]
    [14] unable to open database file’ in /var/www/html/nextcloud/lib/private/DB/Connection
    .php:60\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/
    Doctrine/DBAL/Connection.php(973): OC\\DB\\Connection->connect()\n#1 /var/www/
    html/nextcloud/lib/private/DB/Connection.php(215): Doctrine\\DBAL\\Connection->
    executeUpdate(‘PRAGMA read_unc…’, Array, Array)\n#2 /var/www/html/nextcloud/
    3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): OC\\DB\\Connection->
    executeUpdate(‘PRAGMA read_unc…’)\n#3 /var/www/html/nextcloud/lib/private/DB/
    Connection.php(147): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#4 /
    (172): OC\\DB\\Connection->__construct(Array, Object(Doctrine\\DBAL\\Driver\\
    PDOSqlite\\Driver), Object(Doctrine\\DBAL\\Configuration), Object(Doctrine\\
    Common\\EventManager))\n#5 / in /var/www/html/nextcloud/lib/private/DB/Connection.
    php on line 60, referer:
    [Sun Feb 05 14:33:05.904833 2017] [:error] [pid 3456] [client]
    PHP Fatal error: Uncaught exception ‘Doctrine\\DBAL\\DBALException’ with message
    ‘Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [14]
    unable to open database file’ in /var/www/html/nextcloud/lib/private/DB/Connection.php:60
    \nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/
    Connection.php(973): OC\\DB\\Connection->connect()\n#1 /var/www/html/nextcloud/lib/
    private/DB/Connection.php(215): Doctrine\\DBAL\\Connection->executeUpdate(‘PRAGMA read_unc…’,
    Array, Array)\n#2 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.
    php(621): OC\\DB\\Connection->executeUpdate(‘PRAGMA read_unc…’)\n#3 /var/www/html/nextcloud/
    lib/private/DB/Connection.php(147): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#4 /
    var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\
    Connection->__construct(Array, Object(Doctrine\\DBAL\\Driver\\PDOSqlite\\Driver), Object
    (Doctrine\\DBAL\\Configuration), Object(Doctrine\\Common\\EventManager))\n#5 / in /var/www/html
    /nextcloud/lib/private/DB/Connection.php on line 60, referer:

    There is obviously lots wrong…

    • Hi Debonaire,

      The output above is basically the same (long) line repeated twice, showing that Nextcloud cannot connect to the database. Here is the significant bit: “SQLSTATE[HY000] [14] unable to open database file”.

      This is why you get the blank screen. It is difficult to say what the problem is with the database. Did you make any changes apart from what is in the procedure ? I would try repeating the procedure from the start and see if it works.

  10. Just to let everyone who will follows this thread just follow Jim’ s instructions line by line and Nextcloud will be installed no problems. Jim is a real Posix man…

    • Will this replace an existing but non-functional installation of nextcloud? Let me describe where I have arrived at, As Ii said in my previous comment, follow Jim’s instructions and all will go well. The rub is that once you transfer the nextcloud data directory to an external USB HD, nextcloud fails, you get a blank page! The installation worked very well from the SD card,but the storage capacity even with my 64 GB card is limited, hence why I chose to trnasfer to USB storagedevice. I followed Jim’ s instructions from his owncloud tutorial, substituting nextcloud references for owncloud references.

      Here is what the sudo ls -l /myusbdisk/nextcloud/data lists after a lengthy wait accessing the disk:

      ls: cannot access /mnt/nextcloud/data/owncloud.db-shm: Structure needs cleaning
      ls: cannot access /mnt/nextcloud/data/owncloud.db-wal: Structure needs cleaning

      The listing after that makes sense, showing users etc…

      In any case good on you Nachoparker for helping the community

      • Hi Debonaire, note that the error message “Structure needs cleaning” is quite unusual in Linux, and needs your attention. It comes from the EXT4 file system, and indicates file system corruption. I would recommend fixing it before continuing to use the disk. Personally I’ve not encountered the “Structure needs cleaning” error, but it doesn’t seem too difficult to repair. Search on Google or check this out:


        • After tinkering on and off this is what I conclude. As I said above everything works fine if all is on the sd card, specifically data in /var/nextcloud/data and the config.php file in /var/www/html/nextcloud/config, again on the sd card. The reason the data directory was moved to /var/nextcloud comes from Jim’ s suggestion in the tutorial… I think there is more to transferring the data directory from the sd card at /var/nextcloud/data to a USB drive at say /mnt/nextcloud/data and changing the config.php to point to the USB directory. Config.php in my installation -which follows the above instructions- sits at /var/www/html/nextcloud/config. I think this may be the problem, it should be elsewhere, but I could be wrong. Any suggestions are welcome…

          • Hi Debonaire

            The correct location of the config file is /var/www/html/nextcloud/config/config.php, as detailed in the procedure. Cheers, Jim

  11. Thanks to all, Jim especially and you Nachoparker. These exhanges are very civilized and non-hostile, as is too often the case on web forums.

  12. This install went absolutely painlessly on my rpi. Thanks!

    Now to figure out how to get it to share a calendar amongst the user accounts. The necessary section for the manual hasn’t been written yet.

    • Great, Karsten. The calendar sharing function still seems a bit doubtful on Nextcloud. They will probably get it running properly in a couple of months. You might have to upgrade though. Jim.

  13. Thank you Jim for this article, I’ve installed NextCloud on my 120GB SSD giving me over 100GB of available storage and it’s fast too 🙂

    I made a folder in /home/”username”/cloud-data to keep it away from the default site and just did:
    sudo chown -R www-data:www-data /home/”username”/cloud-data

    I did this before I created the admin.

    Now to find a https tutorial 🙂

    Thanks again,

  14. Great tutorial!

    But I got stuck at

    Change this line:
    ‘datadirectory’ => ‘/var/www/html/nextcloud/data’,
    to this:
    ‘datadirectory’ => ‘/var/nextcloud/data’,

    Basically screwed up the vi editing. Can I get some tips on how to go about doing that?

    • Hi Ak. Sorry to hear the edit did not go right. Having followed the procedure, you should have a backup file, created just before the edit, called “”. Just delete your messed up file and copy the original back into place:

      $ cd /var/www/html/nextcloud/config
      $ sudo rm config.php
      $ sudo cp config.php

      and try the edit again:

      $ sudo vi config.php

      If you don’t like vi, try another editor.

  15. Thank you very much for the great tutorial!
    I just have a question regarding the use of SQLite as the DB. Since during the the completion of the Nextcloud setup on the web interface it is written that SQLite is not recommended for Nextcloud. Since the performance is supposed to be worse than MySQL.
    Will I have huge performance problems with SQLite? Since I will be the only user on my Nextcloud at the moment and in my short upload and download tests the performance was satisfactory for my use.

    Thanks in advance.

    • Hi Carello. With a small system such as a Raspberry Pi, SQLite is an appropriate choice. MySQL is a powerful database system, much more sophisticated than SQLite, and is usually intended for much bigger workloads. MySQL also uses more system resources such as CPU and memory, and is more complicated to set up. As you are the only user, the performance of SQLite should be fine. I don’t think performance would be any better with MySQL. But both will work.

  16. Hello everyone…

    I thought it appropriate to bring things referred to in my comments to a conclusion. I was finally able to get Nextcloud to work on an external HD, i.e. where the data is stored. I don’t know exactly what errors I may have made in my first try or two. My advice is to really mind mounting the USB drive permanently in the first instance, lots of info. out there on that. Then proceed to copy the data directory from the sd card to the USB drive and changing the entry in the config.php file.

    All that is in Jim’ s tutorial works well…

  17. Hi,

    Would like to ask how to update nextcloud if there is an update. currently there is an update 11.0.2 and i want to update to that. please help

    • Hi Ace. Unfortunately I haven’t yet written a section for updating Nextcloud. All I can suggest is starting from the beginning with a fresh Pi install and the latest version of Owncloud.

      • that sucks as i have already started and have put alot of time personalizing the contacts page and other things. feelsbadman

        • Hmm. Well, if you check my earlier (and now obsolescent) article on installing Owncloud (Nextcloud’s predecessor), here:, there is a section called “Upgrading Owncloud to Vsersion 8.2.2 (on Wheezy)”.

          Although the versions are out of date, the same basic procedure will *probably* work for upgrading to Nextcloud 11.0.2. Remember the old procedure was for Wheezy, so the paths change from /var/www to /var/www/html.


          • btw. I simply updated to 11.0.2 from my web-interface, logged in as the admin.
            Went perfectly fine. So, I’m not sure why the frustration. Just go ahead and follow the instructions.

  18. Hi, I was going to backup my nextcloud install following the official guide:
    Backing up the data directory was straight forward. But I struggle with the database.
    Maybe I have an old version of your script but I only seem to have mysql installed and not sqlite3.
    Also, I’m not sure what Database I would have to backup? All three (mysql, sqlite, postreSQL)? Or only one of them? Do you have any advice?

    • btw, I just realized that I have the mysql version installed. So, I guess I would only have to backup mySQL doing this:

      mysqldump –lock-tables -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +”%Y%m%d”`.bak

      Now (I fell very silly) where do I find the ‘server’, and ‘db_name’? Any idea?

      • Hi Filippo. You can tell if MySQL is running by just looking for the process:

        $ ps -elf | grep -i mysql

        Your server would just be the local machine (your Pi), Regarding the database name, it is set during installation. By default it is “nextcloud”, try that.

        Incidentally, I backup MySQL by stopping the database, taking a copy of the database files, starting the database again (so that it was only down for a short while), then backing up the copied files, eg.

        $ sudo /etc/init.d/mysql stop
        $ sudo tar -cf /var/lib/mysql.tar. /var/lib/mysql
        $ sudo /etc/init.d/mysql start

        Then I just copy the file /var/lib/mysql.tar off to some backup location.

  19. Pingback: Personal cloud storage on the Orange Pi - Pi Projects

  20. Thanks for the help, but I’m stuck at this point:

    sqlite> update oc_storages set id=”local::/var/nextcloud/data/”


  21. Hi Jim. I have a feeling that I have the same problem as Vincenzo. The error I receive is: Error: no such table: oc_storages. Any help would be appreciated.

    • Hi Andy. I am not sure why it would say “no such table”. However, if that part didn’t work, I don’t think it is a big problem. Your Nexcloud installation will likely work anyway, even without those SQLite commands.

  22. Like a poster above, I’ve tried a few tutorials on installing NextCloud and agree completely that yours is far and away the clearest and cleanest out there… thank you for the great tutorial and also for your continued Q&A access.

    I do have a question about the sqlite commands in the “Secure the Nextcloud Data Directory” section.

    Re: the command – “sqlite> update oc_storages set id=”local::/var/nextcloud/data/” where id like ‘%local%’;”

    My moved my data file to an external USB drive ” /disk/nextcloud/data” . Is that still considered “local”? Do I just replace “/var” with “/disk”?



  23. Hi Jim, thank you very much for such detail instruction. I was able to get everything working with RP3 + 2 TB External USB HDD formatted with EXT4. The only problem if I restart my RPi3 the HDD becomes unmounted so I cannot access nextcloud until I manually remount the HD. Is there a detail command line to make the HD auto mount if the RPi restart. Thanks in advance.

    • Hi Sam. Is there an entry in /etc/fstab for the disk? If not, add line to the /etc/fstab file, something like this:

      /dev/sdb1 /var/nextcloud ext4 defaults 0 0

      …where “/var/nextcloud” is the place you want to mount the disk, and “/dev/sdb1” is disk device. You can then mount the disk by just typing “sudo mount /var/nextcloud” (or whatever mount point you have chosen). It should also mount automatically at boot.

  24. Thank you very much Jim for the quick replied. This is what I have in the /etc/fstab:
    proc /proc proc defaults 0 0
    PARTUUID=f5a7a508-01 /boot vfat defaults 0 2
    PARTUUID=f5a7a508-02 / ext4 defaults,noatime 0 1
    # a swapfile is not a swap partition, no line here
    # use dphys-swapfile swap[on|off] for that

    Then I added this line at the bootom, safe and exit:
    /dev/sdb1 /disk/nextcloud ext4 defaults 0 0

    Next when I type:
    sudo mount /disk/nextcloud

    this is what I got:

    mount: special device /dev/sdb1 does not exist

  25. Hello Jim, thank very much for your help. I finally got it working (2 TB USB HDD auto mount even the RP3 reboot) by following your suggestion above. What I did was adding this line:

    /dev/sda1 /disk/nextcloud ext4 defaults 0 0

    in /etc/fstab then safe and exit. Then mount the drive.

    Now the last thing to do is to setup HTTPS. Any suggestion? (I’m new to linux) 🙁

    • Glad you have got the mount working, Sam. /dev/sda1 is the device of your disk, so now it mounts properly.

      Converting a website to HTTPS is quite a long procedure. Sooner or later I will write an article on that, but I haven’t had time yet.


      • Hello Jim,
        Yes, got everything working working then messed it up while trying to set up https with letuscript. Good thing I have image the working sd card. So just need to burn the backup image back to sdcard.
        Waiting for your excellent instruction on setting up https and accessing from outside. Have a good day!

        • Cheers Sam, I will write that article some day, and put a note about it here. It is good that you have an image to “roll back” to, and demonstrates the importance of backups!

  26. Hello,
    I don’t know if what I’s like is possible but I’m sure you’ll have a quick answer for me.
    I would like to store my data at home without encryption and have an automatic backup on a Google drive with encryption. Or even store an encrypted copy on a friend cloud (and he will store his files encrypted at my place).

    • Hi zurpa, pardon the delay in replying. I am not a user of Google drive, and so it is difficult to advise. The general principle would be to encrypt your data and then send it to Google drive. Most backup tools offer encryption. Try to set your backup program to use Google drive as the backup target, and turn on encryption. Cheers, Jim.

  27. I have also moved my data to another mounted location.
    Upon running the below and attempting to update the SQLite table with:
    “update oc_storages set id=”local::/var/nextcloud/data/” where id like ‘%local%’;”

    I get the error “Error: no such table: oc_storages” and now my nextcloud installation will not work, if I attmept to head to it get :
    “Internal Server Error
    The server encountered an internal error and was unable to complete your request.
    Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
    More details can be found in the server log.”

    Any help would be appreciated !

    • Hi Nathan. The update command failed because it could not find the oc_storages table. The command terminated without making any changes, so it will not have been the cause of the “internal server error”. To get more information, load the web page again. When the “internal server error” message appears, check the Apache error log as follows:

      $ tail /var/log/apache2/error.log

      Some helpful message should then appear in the terminal, allowing the problem to be diagnosed.

  28. This procedure worked like a charm, and I managed to successfully move data to the external drive.
    I did run into a few issues, but it was all my bad – typos were the basic issue. Also, Nathan if you have moved the data folder to an external drive then the path will no longer be /var/, it will change to your mounted media /media/ or /sda?/…. I was getting the same error. I also found out that the permission had to be re-setup as you moved physical drives – they don’t automagically inherit across physical devices… go figure in this day and age…
    Anyway, setup the permission with CHMOD and then CHOWN, make sure the path is corrected to the mounted drive /media/… and you should be good to go!
    Thanks for the tutorial, and NextCloud is so much better than OwnCloud – smoother 😉

    • Cheers David, glad it worked. In a few days I will be publishing an another article to do the Nextcloud installation automatically.

Leave a Reply

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