I screwed up ... upgraded my Debian server before putting Nextcloud into maintenance mode ... any way out of this?

Nextcloud version: 23.0.11.1 (I think. The last 23-version that supports php 7.3)
Operating system and version: Debian 10 - buster
Apache or nginx version: Apache 2.4.38
PHP version: 7.3 before; server upgrade to 8.2; now switching between 7.3, 7.4, 8.1, and 8.2 ... Nextcloud does not work with any of them.


The issue you are facing:

Nutshell: Trying to upgrade my server php beyond 7.3 and Nextcloud … I ran sudo apt update & apt upgrade before taking Nextcloud into maintenance mode, and now I cannot get Nextcloud working, no matter which version of php I use.

Now I have php version 7.3, 7.4, 8.1 and 8.2 all installed and usable. PhpInfo informs me that I am validly switching between versions (running on Apache, not using FastCGI).

Running php 7.3 or 7.4, on the website, I get a simple “Internal Server Error” – “The server encountered an internal error and was unable to complete your request.” … Running php 8.1 or 8.2 gets a slightly more helpful “This version of Nextcloud is not compatible with > PHP 8.0.” error message.

In the terminal, running the “php occ maintenance:mode --on” command throws a “can’t find DB driver” error followed by a long stacktrace.

Relatedly, after my server upgrade, all of my mysql users stopped being able to log in. Error 1045 – there’s a lot of stuff out there about that, and I eventually worked that out by regranting full permissions to the necessary user accounts.

For a minute, I thought/hoped that was the entire problem with Nextcloud, too … but no … my “nextcloud_user” account now works fine, has proper access, and the Nextcloud occ utility still throws the DB driver error.

At this point, I was preparing to do the manual upgrade process as described in the Nextcloud manual … but since I did not put it into maintenance mode first, I expect there will be issues within the database when I try to fire up the new version. So I figured I better check in here, before I do any more damage.


Is this the first time you’ve seen this error? (Y/N): Yes


Steps to replicate it:

  1. Have Nextcloud 23 running on old, Debian 10 server that hasn’t been updated in a few months.
  2. Upgrade the server using apt update && apt upgrade without first putting Nextcloud into maintenance mode.

The output of your Nextcloud log in Admin > Logging:

I'm not clear where this comes from, but if it comes from the still-working website's admin area, that's not an option for me.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => '99.99.99.99',
    1 => 'mywebsite.com',
    2 => 'www.mywebsite.com',
  ),
  'datadirectory' => '/disk1/mywebsite/nextcloud_data',
  'dbtype' => 'mysql',
  'version' => '23.0.11.1',
  'overwrite.cli.url' => 'http://99.99.99.99/nextcloud',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud_user',
  'dbpassword' => '',
  'installed' => true,
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'me',
  'mail_domain' => 'mywebsite.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => 'mysmtp.host',
  'mail_smtpport' => '465',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'theme' => '',
  'loglevel' => 1,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'logfilemode' => 416,
  'logdateformat' => 'F d, Y H:i:s',
  'mysql.utf8mb4' => true,
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'me@my.email',
  'mail_smtppassword' => '',
  'updater.release.channel' => 'stable',
);

The output of your Apache/nginx/system log in /var/log/____:
The relevant error-log message (repeated a lot) seems to be this–

PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/html/nextcloud/lib/private/DB/Connection.php:87\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\\DB\\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\\DBAL\\Connection->getWrappedConnection()\n#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(237): Doctrine\\DBAL\\Connection->executeQuery()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\\DB\\Connection->executeQuery()\n#4 /var/www/html/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#5 /var/www/html/nextcloud/lib/private/AppConfig.php(361): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#6 /var/www/html/nextcloud/lib/private/AppConfig.php(126): OC\\AppConfig->loadConfigValues()\n#7 /var/www/html/nextcloud/lib/private/AppConfig.php(317): in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 87

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.
Tail /var/log/nextcloud.log gives me this…

{"reqId":"h39QFb9IZmmSMynm27MU","level":1,"time":"December 26, 2022 15:17:21","remoteAddr":"99.99.99.99","user":"me","app":"no app in context","method":"GET","url":"/index.php/settings/ajax/checksetup","message":"Deprecated event type for OCP\\IDBConnection::CHECK_MISSING_INDEXES: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0","version":"23.0.11.1","data":[]}
{"reqId":"h39QFb9IZmmSMynm27MU","level":1,"time":"December 26, 2022 15:17:22","remoteAddr":"99.99.99.99","user":"me","app":"no app in context","method":"GET","url":"/index.php/settings/ajax/checksetup","message":"Deprecated event type for OCP\\IDBConnection::CHECK_MISSING_COLUMNS: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0","version":"23.0.11.1","data":[]}
{"reqId":"dIe4ipJFwpH9lrN5jSi2","level":3,"time":"December 26, 2022 15:20:01","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"rename(/var/log/nextcloud.log,/var/log/nextcloud.log.1): Permission denied at /var/www/html/nextcloud/lib/public/Log/RotationTrait.php#52","userAgent":"--","version":"23.0.11.1","exception":{"Exception":"Error","Message":"rename(/var/log/nextcloud.log,/var/log/nextcloud.log.1): Permission denied at /var/www/html/nextcloud/lib/public/Log/RotationTrait.php#52","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"rename(/var/log/nextcloud.log,/var/log/nextcloud.log.1): Permission denied","/var/www/html/nextcloud/lib/public/Log/RotationTrait.php",52,["/var/log/nextcloud.log.1"]]},{"file":"/var/www/html/nextcloud/lib/public/Log/RotationTrait.php","line":52,"function":"rename","args":["/var/log/nextcloud.log","/var/log/nextcloud.log.1"]},{"file":"/var/www/html/nextcloud/lib/private/Log/Rotate.php","line":44,"function":"rotate","class":"OC\\Log\\Rotate","type":"->","args":[]},{"file":"/var/www/html/nextcloud/lib/private/BackgroundJob/Job.php","line":51,"function":"run","class":"OC\\Log\\Rotate","type":"->","args":[null]},{"file":"/var/www/html/nextcloud/cron.php","line":151,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"/var/www/html/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
{"reqId":"dIe4ipJFwpH9lrN5jSi2","level":2,"time":"December 26, 2022 15:20:01","remoteAddr":"","user":"--","app":"OC\\Log\\Rotate","method":"","url":"--","message":"Log file \"/var/log/nextcloud.log\" was over 104857600 bytes, moved to \"/var/log/nextcloud.log.1\"","userAgent":"--","version":"23.0.11.1","data":{"app":"OC\\Log\\Rotate"}}
{"reqId":"kjC4BSZMGuvcSNxOyNRQ","level":3,"time":"December 26, 2022 15:25:01","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"rename(/var/log/nextcloud.log,/var/log/nextcloud.log.1): Permission denied at /var/www/html/nextcloud/lib/public/Log/RotationTrait.php#52","userAgent":"--","version":"23.0.11.1","exception":{"Exception":"Error","Message":"rename(/var/log/nextcloud.log,/var/log/nextcloud.log.1): Permission denied at /var/www/html/nextcloud/lib/public/Log/RotationTrait.php#52","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"rename(/var/log/nextcloud.log,/var/log/nextcloud.log.1): Permission denied","/var/www/html/nextcloud/lib/public/Log/RotationTrait.php",52,["/var/log/nextcloud.log.1"]]},{"file":"/var/www/html/nextcloud/lib/public/Log/RotationTrait.php","line":52,"function":"rename","args":["/var/log/nextcloud.log","/var/log/nextcloud.log.1"]},{"file":"/var/www/html/nextcloud/lib/private/Log/Rotate.php","line":44,"function":"rotate","class":"OC\\Log\\Rotate","type":"->","args":[]},{"file":"/var/www/html/nextcloud/lib/private/BackgroundJob/Job.php","line":51,"function":"run","class":"OC\\Log\\Rotate","type":"->","args":[null]},{"file":"/var/www/html/nextcloud/cron.php","line":151,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"/var/www/html/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
{"reqId":"kjC4BSZMGuvcSNxOyNRQ","level":2,"time":"December 26, 2022 15:25:01","remoteAddr":"","user":"--","app":"OC\\Log\\Rotate","method":"","url":"--","message":"Log file \"/var/log/nextcloud.log\" was over 104857600 bytes, moved to \"/var/log/nextcloud.log.1\"","userAgent":"--","version":"23.0.11.1","data":{"app":"OC\\Log\\Rotate"}}
{"reqId":"kjC4BSZMGuvcSNxOyNRQ","level":1,"time":"December 26, 2022 15:25:01","remoteAddr":"","user":"--","app":"text","method":"","url":"--","message":"Document 696994 has not been reset, as it has unsaved changes","userAgent":"--","version":"23.0.11.1","data":{"app":"text"}}
{"reqId":"kjC4BSZMGuvcSNxOyNRQ","level":1,"time":"December 26, 2022 15:25:01","remoteAddr":"","user":"--","app":"text","method":"","url":"--","message":"Document 741441 has not been reset, as it has unsaved changes","userAgent":"--","version":"23.0.11.1","data":{"app":"text"}}
{"reqId":"kjC4BSZMGuvcSNxOyNRQ","level":1,"time":"December 26, 2022 15:25:01","remoteAddr":"","user":"--","app":"text","method":"","url":"--","message":"Document 741441 has not been reset, as it has unsaved changes","userAgent":"--","version":"23.0.11.1","data":{"app":"text"}}

NC 23 supports PHP 7.3, 7.4, and 8.0.

PHP 8.0 is recommended for that version, so you should go to that version and stay there while troubleshooting.

Do you have the PHP module for MySQL/Postgres installed? You can find a list of needed modules here. https://docs.nextcloud.com/server/23/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation

Maybe it will be ok. It doesn’t sound like your error is necessarily from that.

These are required to run nc 23. Since you are using 8.1 or 8.2 you must change to an earlier version of php. You can Google or search the forum for more details on defining a specific php version.

UPDATE

Missing PHP modules was my problem.

Switched PHP over to 8.0 (both command-line and apache). Then I identified several missing PHP modules and installed them. Most likely, the critical module was the pdo_mysql, but I added a bunch of others, both required and suggested.

My Nextcloud is back up and running … will now try walking my way thru the upgrade process to version 24.

Thanks for the help.


Nextcloud Pro Tip: When you run apt upgrade to a new version of php, apt gives you a list of “The following packages … are no longer required” … that list is pretty much the list of old php-version modules that you have installed, which you now need to reinstall for the new version.


2 Likes

Here are a few more general tips:

  1. Documentation! Keep notes of your installation steps and configuration changes. I can reinstall PHP in 5 minutes or set up a Nextcloud from scratch in 20 minutes using my notes.

  2. if possible run a separate instance, where you can play around and test updates, before you upgrade your production instance.

  3. Install Nextcloud on a hypervisor that is able to take snapshots of the VMs. Then you can easily revert to a previous working state of the VM if something goes wrong during an upgrade.

2 Likes