Nextcloud Internal Server Error after PHP Upgrade

Nextcloud version: 26.0.1.1
Operating system and version: Ubuntu 22.04.2 LTS
Apache or nginx version: Apache 2.4.25
PHP version: PHP 8.2.5

The issue you are facing:
After trying to upgrade from PHP 8.1 to PHP 8.2 i faced the following Error when I try to access Nextcloud UI:

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.

Is this the first time you’ve seen this error?:
Yes

Steps to replicate it:

  1. Install PHP 8.2 and PHP 8.2-Modules
  2. Change PHP Version from PHP 8.1 to 8.2

The output of your Nextcloud log in Admin > Logging:
Can’t access the Log (UI)

The output of /var/www/nextcloud/config/config.php:

<?php
$CONFIG = array (
  'instanceid' => 'XXX',
  'passwordsalt' => 'XXX',
  'secret' => 'XXX',
  'trusted_domains' =>
  array (
    0 => 'XXX',
    1 => 'XXX',
    2 => 'XXX',
  ),
  'datadirectory' => '/nextcloud-data',
  'dbtype' => 'mysql',
  'version' => '26.0.1.1',
  'overwrite.cli.url' => 'https://XXX',
  'overwriteprotocol' => 'https',
  'dbname' => 'db_nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'usr_nextcloud',
  'dbpassword' => 'XXX',
  'installed' => true,
  'default_language' => 'de',
  'default_locale' => 'de',
  'default_phone_region' => 'DE',
  'defaultapp' => 'files,dashboard',
  'knowledgebaseenabled' => false,
  'allow_user_to_change_display_name' => false,
  'skeletondirectory' => '',
  'mail_from_address' => 'XXX',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'XXX',
  'mail_smtpsecure' => 'ssl',
'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'XXX',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'XXX@XXX',
  'mail_smtppassword' => 'XXX',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'maintenance' => false,
  'app_install_overwrite' =>
  array (
    0 => 'nextbackup',
    1 => 'ownbackup',
  ),
  'theme' => '',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____:

[Wed May 03 13:44:04.711158 2023] [mpm_prefork:notice] [pid 14811] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 03 13:44:27.122598 2023] [ssl:warn] [pid 950] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:44:27.152738 2023] [ssl:warn] [pid 1025] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:44:27.155093 2023] [mpm_prefork:notice] [pid 1025] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed May 03 13:44:27.155130 2023] [core:notice] [pid 1025] AH00094: Command line: '/usr/sbin/apache2'
[Wed May 03 13:47:03.004367 2023] [mpm_prefork:notice] [pid 1025] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 03 13:47:03.063169 2023] [ssl:warn] [pid 14109] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:47:03.073012 2023] [ssl:warn] [pid 14110] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:47:03.074415 2023] [mpm_prefork:notice] [pid 14110] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed May 03 13:47:03.074446 2023] [core:notice] [pid 14110] AH00094: Command line: '/usr/sbin/apache2'
[Wed May 03 13:49:25.882723 2023] [mpm_prefork:notice] [pid 14110] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 03 13:49:25.951148 2023] [ssl:warn] [pid 16451] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:49:25.961436 2023] [ssl:warn] [pid 16452] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:49:25.962812 2023] [mpm_prefork:notice] [pid 16452] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed May 03 13:49:25.962845 2023] [core:notice] [pid 16452] AH00094: Command line: '/usr/sbin/apache2'
[Wed May 03 13:53:45.200189 2023] [mpm_prefork:notice] [pid 16452] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 03 13:53:45.275118 2023] [ssl:warn] [pid 17725] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:53:45.285761 2023] [ssl:warn] [pid 17726] AH01909: XXX:443:0 server certificate does NOT include an ID which matches the server name
[Wed May 03 13:53:45.287242 2023] [mpm_prefork:notice] [pid 17726] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed May 03 13:53:45.287275 2023] [core:notice] [pid 17726] AH00094: Command line: '/usr/sbin/apache2'

Installed PHP-Modules:

libapache2-mod-php8.2/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
libapache2-mod-php/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-bcmath/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-common/jammy,now 2:93+ubuntu22.04.1+deb.sury.org+2 all [installed,automatic]
php-curl/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-dev/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-gd/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-gmp/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-imagick/jammy,now 3.7.0-3+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php-intl/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-json/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-mbstring/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-mysql/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-pear/jammy,now 1:1.10.12+submodules+notgz+20210212-1ubuntu3 all [installed,automatic]
php-xml/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php-zip/jammy,now 2:8.2+93+ubuntu22.04.1+deb.sury.org+2 all [installed]
php8.2-bcmath/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-bz2/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-cli/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed,automatic]
php8.2-common/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-curl/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-dev/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed,automatic]
php8.2-fpm/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-gd/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-gmp/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-imagick/jammy,now 3.7.0-3+ubuntu22.04.1+deb.sury.org+1 arm64 [installed,automatic]
php8.2-intl/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-mbstring/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-mysql/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-opcache/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed,automatic]
php8.2-readline/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed,automatic]
php8.2-xml/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
php8.2-zip/jammy,now 8.2.5-1+ubuntu22.04.1+deb.sury.org+1 arm64 [installed]
pkg-php-tools/jammy,now 1.42build1 all [installed,automatic]

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.

You have installed libapache2-mod-php8.2 and php8.2-fpm

Which of the two do you use? It’s either one or the other.

How did you do step 2? With update-alternatives --all or did you take any further steps?

I would remove the ‘app_install_overwrite’ array, since multiple entries from your log file are complaining about the listed app nextbackup:

"App nextbackup threw an error during app.php load and will be disabled: Class \"OCP\\App\" not found"

Furthermore, your log file complains that it lost connection to the database:

"An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away"

and about errors with Redis:

    "Exception": "RedisException",
    "Message": "Connection lost",

That’s enough starting points to solve.

You did not install the redis module:

sudo apt-get install php8.2-redis
1 Like

I read that Nextcloud doesn’t support PHP 8.2 so far, so i fully removed PHP 8.2 and reinstalled 8.1 with all the required modules.
Now its working great.

Thanks for your help

After looking at almost every page on the internet, this is the right answer to my problem. I had running php 8.0 and nextcloud on my Raspberry pi. When i switched to php 8.2 with a2dismod and a2enmod and restarting ect. i stoped working althou phpinfo did tell me it was running fine 8.2. Tried a lot of thins including installing all kind modules. But finaly i have it running again. Thanks ernolf

1 Like

Next time straight to [-> php-updater <-] :wink:

graag gedaan Willem, ik ben blij dat het je heeft geholpen!

Veel geluk,
ernolf

1 Like

:thinking: This post is from May 2023.
January 2024 php 8.2 is recommended.

image

Dear ernolf,

I am facing a similar problem. I updated nextcloud-apache via zypper to php 8.2; php seems to work and nextcloud-sync via the official clients (Windows and Android) works without any problems, only I can’t reach my nextcloud installation via the web interface anymore… I keep getting an “Internal Server Error”

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.

I read too late that your script existed and also read somewhere that it would only work for “ubuntu” (debian) installations while I am working on an opensuse server (redhat) …

My bash knowledge is pretty basic, I scrolled through your script but my knowledge doesn’t go far enough to be convinced if it would work on my installation too. Also, php8.2 and the new version of “nextcloud-apache” is already active on my server.

Any idea if I could “port” your script to a redhat-based server (opensuse)? If so, where in the script would I need to make adjustments? Do I need to downgrade apache and/or php again first?

Thanks in advance for your help.

@ernolf excuse me for the text in Dutch, I translated it to English so everyone can read it.

No. It is too deeply dependent on the Debian system for that. So it only works with dpkg (and apt, apt-get) but is not made for rpm-based distributions.
It is also not easy to transfer, because it is closely related to the Debian special composition by the package maintainer.

Unfortunately.

If I ever have some time to focus more on rpm-based Linux, I might try that again, but I’d rather not take that into account.


Veel geluk,
ernolf

ok thanks for your reply, it’s clear I cannot use the script for now.
do you have any idea how I can manually fix my “internal server error” problem or where I can start to look to analyse the problem?
So I said before the nextcloud-sync is working perfectly so I guess php and mariadb are working…?

Analise the logfiles (access.log and error.log) from your apache2 server.


Much and good luck,
ernolf

I fixed it by running the phar-upgrader! (majour upgrade to v28)
the occ upgrade nor the maintenance:repair did not do that.

happy and releaved now :slight_smile: