Jeremy Davis's picture

[UPDATE for v15.x] Please note that as of v15.x Nextcloud is installed to /var/www/nextcloud so the paths noted in this thread will need to be adjusted. Also, ownership to the /var/www/nextcloud directory will need to be given to the webserver user (www-data). I.e. "chown -R www-data:www-data /var/www/nextcloud". Otherwise the instructions should be relevant.

I just had a question via email regarding how to update NextCloud to the latest version on our NextCloud appliance. Rather than just answer via email, I thought it'd be best to post on the forums so everyone can benefit. Here's the original question:

I was able to ssh to my nextcloud virtual machine in Proxmox, but from there commands in the "nextcloud guide" to upgrade are mostly not working and useless, sudo does not exist too. I have done logon with user "root" and "nextcloud" as password, my nextcloud user is another instead, and I'm unable to ssh with my nexclout user and password.

For starters, there is no need to use a separate 'nextcloud' Linux user account. All you should need is 'root'. The NextCloud software runs as the webserver user (www-data). If you explictly want to set up a new user account (and not use root) please start a new thread asking about that and I'll respond.

Please note that I haven't tested anything I post here, so if it doesn't work, please let me know (and post the output your get) and I'll try to help resolve it.

On face value it appears to have a fairly simple workaround. The NextCloud manual upgrade instructions are pretty close and only need minor tweaking to apply to the TurnKey appliance.

Firstly, my guess is that you'll either need to run the 'occ' command within the NextCloud application directory, or you'll need to provide the full path to 'occ'. FWIW in v14.2 NextCloud is installed to /usr/share/nextcloud. For the next release we'll move that to /var/www/nextcloud, which is where most users would expect it. I'll use the full path for now, but if that doesn't work, perhaps try 'cd /usr/share/nextcloud' first.

Furthermore, as you note, TurnKey doesn't have sudo installed. That can be worked around a few different ways:

  1. install sudo
  2. use the 'su' command to achieve the same ends as 'sudo'
  3. or change the order that the processes are done i.e. run the update first as root, then change ownership to the webserver user (www-data)

option 1

Installing software from the Debian repos is super simple:

apt-get update
apt-get install sudo
Then just provide the full path to 'occ' like this:
sudo -u www-data php /usr/share/nextcloud/occ upgrade

option 2

Instead of running the command in step 11; instead run this:

su - -s /bin/bash  www-data -c 'php /usr/share/nextcloud/occ upgrade'

option 3

When you get to step 9, instead of running that, instead skip straight to step 11. Then drop the sudo, so instead something like this:

php /usr/share/nextcloud/occ upgrade

Note: I have struck out "option 3" as I have discovered that it won't work because Nextcloud update script will not run as root!

wrap up

So hopefully that works for you, if not, please post back with info on what went wrong (exactly copy/pasting the explicit error messages is useful if you can).
4ps4all's picture

hi, I managed to upgrade the nextcloud appliance. I added some example command I used to the guide for the manual upgrade.

Option 1

was not working, the command error was:

Nextcloud is allready latest version

Option 3 I didn't tested it.


Upgrade Manually

Always start by making a fresh backup and disabling all 3rd party apps.

  1. Back up your existing Nextcloud Server database, data directory, and config.php file. (See Backup, for restore information see Restoring Backup)

  2. Download and unpack the latest Nextcloud Server release (Archive file) from into an empty directory outside of your current installation.


    To unpack your new tarball, run: unzip nextcloud-[version].zip

    To copy the file nextcloud-[version].zip you can use

#scp filetocopy root@NextcloudContainerIP:\directory

  1. Stop your Web server.


    this command seems to work

    #apachectl stop

    this command doesn’t work

    #apache2ctl status

    /usr/sbin/apache2ctl: 101: /usr/sbin/apache2ctl: www-browser: not found 'www-browser -dump http://localhost:80/server-status' failed. Maybe you need to install a package providing www-browser or you need to adjust the APACHE_LYNX variable in /etc/apache2/envvars


  2. Rename your current Nextcloud directory, for example nextcloud-old.

    #mv /usr/share/nextcloud /usr/share/nextcloud/old

  3. Unpacking the new archive creates a new nextcloud directory populated with your new server files. Copy this directory and its contents to the original location of your old server, for example /var/www/, so that once again you have /var/www/nextcloud.

    #unzip nextcloud-[version].zip

    #mv /NewunzippedNextcloudVersione /usr/share/nextcloud

  4. Copy the config.php file from your old Nextcloud directory to your new Nextcloud directory.

    #cp /usr/share/nextcloud-old/config/config.php /usr/share/nextcloud/config/

  5. If you keep your data/ directory in your nextcloud/ directory, copy it from your old version of Nextcloud to your new nextcloud/. If you keep it outside of nextcloud/ then you don’t have to do anything with it, because its location is configured in your original config.php, and none of the upgrade steps touch it.

    #cp -r /usr/share/nextcloud-old/data /usr/share/nextcloud/data

    Note: if you’re using a VirtualMachine/Container and your /data folder is not in another virtualdisk, or external disk, you must be sure to have enough space to copy all the /data folder. After the upgrade do I have to delete the old /Data directory ??


  6. If you are using 3rd party applications, look in your new nextcloud/apps/ directory to see if they are there. If not, copy them from your old apps/ directory to your new one. Make sure the directory permissions of your third party application directories are the same as for the other ones.

    #cp -r /usr/share/nextcloud/apps/Name_of_theAPP /usr/share/nextxloud/apps

    (Name of the 3rd party app can be calendar,contacts,deck,music,notes if you were using that apps)

  7. Adjust file ownership and permissions:

    chown -R www-data:www-data nextcloud-main-directory 
    find nextcloud/ -type d -exec chmod 750 {} \;
    find nextcloud/ -type f -exec chmod 640 {} \;
    #chown -R www-data:www-data /usr/share/nextcloud
    #find nextcloud/ -type d -exec chmod 750 {} \;
    #find nextcloud/ -type f -exec chmod 640 {} \;
  8. Restart your Web server.

    #apachectl start

  9. Now launch the upgrade from the command line using occ, like this example


su - -s /bin/bash  www-data -c 'php /usr/share/nextcloud/occ upgrade'
	IT WORKED to upgrade from 11.0.1 to 12.0.3
  1. The upgrade operation takes a few minutes to a few hours, depending on the size of your installation. When it is finished you will see a success message, or an error message that will tell where it went wrong.

Login and take a look at the bottom of your Admin page to verify the version number. Check your other settings to make sure they’re correct. Go to the Apps page and review the core apps to make sure the right ones are enabled. Re-enable your third-party apps.

Jeremy Davis's picture

Thanks for posting with further detail and feedback on the instructions that I gave.

FWIW, I don't think option 3 will work either as I've since discovered that NextCloud will not allow you to run the update script as root. I'll update the OP and strike that out.

Add new comment