Migration failed after an upgrade Debian 10 to 11

Hi,

I have a Nextcloud server (the last with PHP 7.3) and I decided to upgrade :slight_smile:

I upgraded first my debian server (10 to 11), to get the 7.4 PHP version. OK

But the running current Nextcloud installation fails to connect from a web navigator (curiously, it seems running ok from the app), with an internal error:

First, it missed:

.ocdata
and apps with write permissions

(Why did it run perfectly before? I did not upgrade Nextcloud!)

Here is the log error:

{"reqId":"W5eysejMVxJJXNdw7l3P","level":3,"time":"2023-12-06T11:34:04+01:00","remoteAddr":"XXXXX","user":"XXX","app":"PHP","method":"GET","url":"/apps/files/","message":"file_put_contents(/var/www/nextcloud/data/appdata_oc3abt42d2e1/css/icons/icons-vars.css): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#282","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0","version":"23.0.12.2","exception":{"Exception":"Error","Message":"file_put_contents(/var/www/nextcloud/data/appdata_oc3abt42d2e1/css/icons/icons-vars.css): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Files/Storage/Local.php#282","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Local.php","line":282,"function":"file_put_contents"},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":258,"function":"file_put_contents","class":"OC\\Files\\Storage\\Local","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1169,"function":"file_put_contents","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":706,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/File.php","line":71,"function":"file_put_contents","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/SimpleFS/SimpleFile.php","line":108,"function":"putContent","class":"OC\\Files\\Node\\File","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/IconsCacher.php","line":145,"function":"putContent","class":"OC\\Files\\SimpleFS\\SimpleFile","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/SCSSCacher.php","line":350,"function":"setIconsCss","class":"OC\\Template\\IconsCacher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/SCSSCacher.php","line":188,"function":"cache","class":"OC\\Template\\SCSSCacher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/CSSResourceLocator.php","line":110,"function":"process","class":"OC\\Template\\SCSSCacher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/CSSResourceLocator.php","line":85,"function":"cacheAndAppendScssIfExist","class":"OC\\Template\\CSSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\Template\\CSSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":353,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":261,"function":"findStylesheetFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":182,"function":"__construct","class":"OC\\TemplateLayout","type":"->"},{"file":"/var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php","line":204,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":171,"function":"render","class":"OCP\\AppFramework\\Http\\TemplateResponse","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1015,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
{"reqId":"W5eysejMVxJJXNdw7l3P","level":3,"time":"2023-12-06T11:34:04+01:00","remoteAddr":"88.183.173.80","user":"adminPK","app":"index","method":"GET","url":"/apps/files/","message":"file_put_contents failed","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0","version":"23.0.12.2","exception":{"Exception":"OCP\\Files\\GenericFileException","Message":"file_put_contents failed","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/SimpleFS/SimpleFile.php","line":108,"function":"putContent","class":"OC\\Files\\Node\\File","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/IconsCacher.php","line":145,"function":"putContent","class":"OC\\Files\\SimpleFS\\SimpleFile","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/SCSSCacher.php","line":350,"function":"setIconsCss","class":"OC\\Template\\IconsCacher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/SCSSCacher.php","line":188,"function":"cache","class":"OC\\Template\\SCSSCacher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/CSSResourceLocator.php","line":110,"function":"process","class":"OC\\Template\\SCSSCacher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/CSSResourceLocator.php","line":85,"function":"cacheAndAppendScssIfExist","class":"OC\\Template\\CSSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\Template\\CSSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":353,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":261,"function":"findStylesheetFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":182,"function":"__construct","class":"OC\\TemplateLayout","type":"->"},{"file":"/var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php","line":204,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":171,"function":"render","class":"OCP\\AppFramework\\Http\\TemplateResponse","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1015,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/Files/Node/File.php","Line":72,"CustomMessage":"--"}}
{"reqId":"W5eysejMVxJJXNdw7l3P","level":3,"time":"2023-12-06T11:34:04+01:00","remoteAddr":"XXXX","user":"XXX","app":"PHP","method":"GET","url":"/apps/files/","message":"chmod(): Operation not permitted at /var/www/nextcloud/lib/private/Log/File.php#86","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0","version":"23.0.12.2","data":{"app":"PHP"}}

Obviously, it seems have a right access permission… But what? Nothing has changed since the previous installation!

Here are the current right:

# ls -al /var/www/nextcloud 
total 168
drwxr-x--- 14 nextcloud www-data  4096  6 déc.  10:09 .
drwxr-xr-x  4 root      root      4096 29 nov.   2018 ..
drwxr-xr-x 45 nextcloud www-data  4096 18 janv.  2023 3rdparty
drwxrwx--- 49 nextcloud www-data  4096 18 janv.  2023 apps
-rw-r--r--  1 nextcloud www-data 19327 18 janv.  2023 AUTHORS
drwxr-x---  2 nextcloud www-data  4096  6 déc.  11:33 config
-rw-r--r--  1 nextcloud www-data  4095 18 janv.  2023 console.php
-rw-r--r--  1 nextcloud www-data 34520 18 janv.  2023 COPYING
drwxr-xr-x 22 nextcloud www-data  4096 18 janv.  2023 core
-rw-r--r--  1 nextcloud www-data  6317 18 janv.  2023 cron.php
lrwxrwxrwx  1 root      root        20 29 nov.   2018 data -> /home/nextcloud/data
-rw-r--r--  1 nextcloud www-data  3442 18 janv.  2023 .htaccess
-rw-r--r--  1 nextcloud www-data   156 18 janv.  2023 index.html
-rw-r--r--  1 nextcloud www-data  3456 18 janv.  2023 index.php
drwxr-xr-x  6 nextcloud www-data  4096 18 janv.  2023 lib
-rw-r--r--  1 nextcloud www-data   283 18 janv.  2023 occ
-rw-r--r--  1 nextcloud www-data     0  6 déc.  10:09 .ocdata
drwxr-xr-x  2 nextcloud www-data  4096 18 janv.  2023 ocm-provider
drwxr-xr-x  2 nextcloud www-data  4096 18 janv.  2023 ocs
drwxr-xr-x  2 nextcloud www-data  4096 18 janv.  2023 ocs-provider
-rw-r--r--  1 nextcloud www-data  3139 18 janv.  2023 public.php
-rw-r--r--  1 nextcloud www-data  5463 18 janv.  2023 remote.php
drwxr-xr-x  4 nextcloud www-data  4096 18 janv.  2023 resources
-rw-r--r--  1 nextcloud www-data    26 18 janv.  2023 robots.txt
-rw-r--r--  1 nextcloud www-data  2452 18 janv.  2023 status.php
drwxr-x---  3 nextcloud www-data  4096 18 janv.  2023 themes
drwxr-x---  2 nextcloud www-data  4096 22 nov.   2018 updater
-rw-r--r--  1 nextcloud www-data   101 18 janv.  2023 .user.ini
-rw-r--r--  1 nextcloud www-data   384 18 janv.  2023 version.php
drwxr-xr-x  3 nextcloud www-data  4096 15 févr.  2022 .well-known

The server runs nginx and was full functionnal before migration…

Thanks for your help… I need then to upgrade to Debian 12 :slight_smile:

Why are all those files owned by user “nextcloud”?
They are normaly all owned by the user running the webserver, wich is www-data on debian.

I’m not entirely sure, but from my point of understanding you should:

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

… then you could make it the other way around, adding user nextcloud to the group www-data.

to make it work.

Even though this looks like it will not make any change, you could at least give it a try. :wink:

Much luck,
ernolf

I created a Nextcloud user on my system to put data on its account. It runs OK like for years (I guess at least 6 or 7 years).

I prefer not to change the owner for the moment :slight_smile:

It would be only a try, you can change back with a similar oneliner :wink:

ernolf

Unfortunately you decided to waste out time and ignore the support template so we can just guess.

in other words you try to run a version of Nextcloud which doesn’t support PHP 7.4 using php74? If yes then you should not. Better upgrade Nextcloud to a version supporting proper PHP before. and once it works continue upgrading until you reach supported NC and PHP version.

you ask for support and decide not follow very reasonable and correct advice? what are you looking for? Official docs reference: files ownership

1 Like

My bad: OK. I found the forum before using the template support. Excuse-me!

hmm? How to do? Nexcloud refuses to upgrade because the PHP version is not enough… It is the way I used the two last times. I upgraded my server, then Nextcloud… Anyway, PHP 7.4 should support PHP 7.3 API!

Because the data are on the nextcloud user homedir and I did not find a good idea ta change all the properties of the account. I tested it finally.

It is working… then thanks to you and Ernolf :+1:

But I don’t still understand why it necessary to change properties of data in Nextcloud although I have changed only the PHP version!

I have to admit I’m too lazy to look through stone age software version but I’m under impression there is always an overlap in Nextcloud versions and supported PHP versions (maybe not with vanilla Debian sources - but this topic was discussed far to often already).

maybe something changed there?

I definitely would recommend you to visit the php74 topics as php 7.4 is out of support since a year and follow the upgrade path straight to php82 and nc27 or maybe NC28 which will be released soon.

Done. I have upgraded to 27, migrating first up to 25 with my Debian 11, then Debian 11 to 12. At this point , the Nextcloud 25 were broken (unsupported PHP 8.2 version) and I had to upgrade to 26 by hands. Finally, I upgraded to 26 without problems by the interface.

Thanks for all.

1 Like