Nextcloud 21.0.4 crashes with PHP 8.0

Hi there,

I’ve updated my server to use PHP 8.0. We’re on Ubuntu 18.04.6 LTS, with nginx 1.18.0, Postgres 10.18, and using Nextcloud 21.0.4.

When swtiching the nginx conf to use /run/php/php8.0-fpm.sock, Nextcloud crashes.

$ sudo -u www-data php /var/www/nextcloud/occ
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:85
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1486): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1014): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(226): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(210): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(345): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(110): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(301): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(965): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(682): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(177): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#21 /var/www/nextcloud/lib/private/Server.php(1031): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#27 /var/www/nextcloud/lib/private/Server.php(1990): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(119): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(430): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#35 /var/www/nextcloud/lib/private/Server.php(1353): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(588): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1076): OC::init()
#38 /var/www/nextcloud/console.php(49): require_once('...')
#39 /var/www/nextcloud/occ(11): require_once('...')
#40 {main}

Nextcloud config is:

<?php
$CONFIG = array (
  'passwordsalt' => '***SENSITIVE-REMOVED***',
  'secret' => '***SENSITIVE-REMOVED***',
  'trusted_domains' =>
  array (
    0 => '***SENSITIVE-REMOVED***'
  ),
  'datadirectory' => '/mnt/nextcloud-data',
  'tempdirectory' => '/mnt/nextcloud-data/***SENSITIVE-REMOVED***',
  'skeletondirectory' => '/mnt/nextcloud-data/***SENSITIVE-REMOVED***',
  'templatedirectory' => '/mnt/nextcloud-data/***SENSITIVE-REMOVED***',
  'dbtype' => 'pgsql',
  'version' => '21.0.4.1',
  'overwrite.cli.url' => '***SENSITIVE-REMOVED***',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '***SENSITIVE-REMOVED***',
  'dbpassword' => '***SENSITIVE-REMOVED***',
  'installed' => true,
  'instanceid' => '***SENSITIVE-REMOVED***',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => 2,
  'logtimezone' => 'Australia/Melbourne',
  'mail_smtpmode' => 'smtp',
  'remember_login_cookie_lifetime' => 0,
  'log_rotate_size' => '10485760',
  'trashbin_retention_obligation' => 'auto, 14',
  'versions_retention_obligation' => 'auto, 365',
  'simpleSignUpLink.shown' => false,
  'login_form_autocomplete' => true,
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => '6379',
    'dbindex' => '0',
    'timeout' => '1.5',
  ),
  'maintenance' => false,
  'default_phone_region' => 'AU',
  'default_locale' => 'en_AU',
  'force_locale' => 'en_AU',
  'default_language' => 'en',
  'force_language' => 'en',
  'defaultapp' => 'activity,files',
  'activity_expire_days' => 180,
  'session_lifetime' => 14400,
  'session_keepalive' => false,
  'auth.webauthn.enabled' => false,
  'overwriteprotocol' => 'https',
  'app_install_overwrite' =>
  array (
    0 => 'activitylog',
    1 => 'files_readmemd',
  ),
  'updater.release.channel' => 'stable',
  'theme' => '',
  'connectivity_check_domains' =>
  array (
    0 => 'nextcloud.com'
  ),
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'notifications',
  'mail_domain' => '***SENSITIVE-REMOVED***',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '***SENSITIVE-REMOVED***',
  'mail_smtpport' => '465',
  'mail_smtpname' => '***SENSITIVE-REMOVED***',
  'mail_smtppassword' => '***SENSITIVE-REMOVED***',
);

Active Apps:

 Accessibility
1.7.0

Activities for shared file downloads
1.11.1
Activity
2.14.3
Announcement center
5.0.0
AppOrder
0.13.0
Auditing / Logging
1.11.0
Brute-force settings
2.2.0
Calendar
2.3.3
Camera RAW Previews
0.7.12
Collaborative tags
1.11.0
Comments
1.11.0
Deck
1.4.4
Deleted files
1.11.0
Draw.io
1.0.1
External sites
3.8.2
Extract
1.3.2
File sharing
1.13.1
First run wizard
2.10.0
Forms
2.3.0
Group folders
9.0.3
Impersonate
1.8.0
Link editor
1.1.6
Log Reader
2.6.0
Metadata
0.14.0
Monitoring
1.11.0
Notes
4.1.1
Notifications
2.9.0
Notifications for calendar event updates
1.3.0
ONLYOFFICE
7.1.2
Password policy
1.11.0
Passwords
2021.9.20
PDF viewer
2.1.0
Photos
1.3.0
Pico CMS
1.0.16
Plain text editor
2.14.0
Preview Generator
3.1.1
Privacy
1.5.0
Quota warning
1.11.0
Ransomware protection
1.11.0
README.md
1.2.0
Recommendations
1.0.0
Right click
1.0.0
Share by mail
1.11.0
Tasks
0.14.2
Text
3.2.0
Theming
1.12.0
Update notification
1.11.0
Versions
1.14.0
Video player
1.10.0
Whiteboard integration
0.0.14

Nextcloud log:

{"reqId":"YKyDNB0cknpjqqtQp7ld","level":3,"time":"2021-09-14T05:59:43+10:00","remoteAddr":"***IP-REMOVED***","user":"--","app":"PHP","method":"GET","url":"/apps/theming/favicon?v=50","message":{"Exception":"Error","Message":"fopen(/mnt/nextcloud-data/data_dir_writability_test_613fadaf9045b.tmp): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#809","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Util.php","line":809,"function":"fopen"},{"file":"/var/www/nextcloud/lib/base.php","line":650,"function":"checkServer","class":"OC_Util","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1076,"function":"init","class":"OC","type":"::"},{"file":"/var/www/nextcloud/index.php","line":35,"args":["/var/www/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0","version":"21.0.4.1","id":"6140404c04aca"}

Is this a bug or a config problem?

A follow up on this one. This occurs even when all apps are disabled.

I’m guessing this line means something is wrong with the core handling Postgres?

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:85

@esxpfe
I do not understand why admins do not use the standard php versions in the corresponding linux releases. And if they need new Nextcloud release why they not upgrade the Ubuntu/Debian release. You can not wait till Ubuntu 22.04 LTS. You must upgrade to Ubuntu 20.04 LTS also. All normal admins uses now Ubuntu 20.04 LTS and not Ubuntu 18.04 LTS. And Ubuntu 20.04 LTS uses PHP 7.4.

Ubuntu – Package Search Results -- php

Nextcloud is configured to work without php modifications on Ubuntu and Debian.

1 Like

I would say the latter.

How did you install PHP 8 on Ubuntu 18.04?

If you installed PHP 8 from third party sources and you installed the packages explicitly with apt install php8.0-modulename, the new version will be installed in addition to the already installed version and any configuration changes you made to the old version will not be applied to the new version. Check if all needed packages are installed in version 8 and configured accordingly and the php8.0-fpm service is running.

You could also remove the old version and reinstall PHP 8 using the documentation of your initial installation, which you hopefully have.

apt remove php*

apt install php8.0-fpm php8.0-gd php8.0-curl etc...

and than configure everything the same way as you did when you installed Nextcloud for the first time. You can use the same commands and config changes, just change the version number in the package names and in the paths to the config files accordingly.

1 Like

It makes no sense to install PHP 8.0 on Ubuntu 18.04 LTS. That is the truth.
Dist upgrade to Ubuntu 20.04 LTS and then solve all problems.

2 Likes

I would not say that in general. I also have PHP7.4 installed on Ubuntu 18.04 :wink:

It works without problems, you can even use several different PHP versions on one system if you want. And if the OP wants PHP 8.0, he has to install it on Ubuntu 20.04 from third party sources too or wait until Ubuntu 22.04 comes out.

But yes you are right that it is easier to just use the version that comes with it and just do a do-release-upgrade every two years. Although, in my experience, even that usually requires a little manual work. Even though PHP has never changed anything fundamental in the config files lately.

2 Likes

Thanks for the replies.

I ran:

sudo apt install php8.0 php8.0-{fpm,cli,common}

… from ppa:ondrej/php repository.

And I also made sure all the required extensions are available, according to this.

$ php -v && php -m
PHP 8.0.11 (cli) (built: Sep 23 2021 21:26:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.11, Copyright (c), by Zend Technologies
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imagick
imap
intl
json
libxml
mbstring
memcached
msgpack
openssl
pcntl
pcre
PDO
pdo_pgsql
pgsql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
snmp
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

I think I’ve just done something dumb somewhere as now changing PHP socket back to 7.4, I’m getting “Bad Gateway” from nginx…

This is on my test server anyway, so I might just nuke and reinstall, since I’ve been sitting on this for two weeks already.

Thanks anyway though!