Internal server error after upgrading php

Nextcloud version (eg, 20.0.5): 23
Operating system and version (eg, Ubuntu 20.04): Debian 10
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.4): 7.3 and 7.4

The issue you are facing:

Hi ! To upgrade my nextcloud to version 24, I decided to update php version from 7.3 to 7.4.
I installed php7.4 and many modules as told in the documentation then do a2dismod php7.3 then a2enmod php7.4. I restart the services.

The only issue is whenever I try to access my server I get this message (in a white bg) :

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 tried to go back in php 7.3 but I still have the error.
The main issue is I don’t have any logs showing up.

My config.php :

‘loglevel’ => 0,
‘log_type’ => ‘file’,
‘logfile’ => ‘/var/www/nextcloud/data/nextcloud.log’,
‘logdateformat’ => ‘F d, Y H:i:s’,

nothing in nextcloud.log,
nothing in syslog,
nothing in error.log (apache)
nothing in access.log

Even when configuring php to display logs, nothing. Idk what I’m doing wrong…
I tried reinstalling completly php. Same error.

Also, there is 2 module I can’t install, openssl and session, I get “E: Unable to locate package php7.4-XX”

And here is the list of modules installed :

php-common/buster,now 2:92+0~20220117.43+debian10~1.gbpe0d14e all [installed,automatic]
php7.4-cgi/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-cli/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-common/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-curl/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-fpm/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-gd/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-json/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-mbstring/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-mysql/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-opcache/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed,automatic]
php7.4-readline/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed,automatic]
php7.4-smbclient/buster,now 1.0.6-6+0~20220117.22+debian10~1.gbp04c19d arm64 [installed]
php7.4-xml/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4-zip/buster,now 1:7.4.30-2+0~20220625.68+debian10~1.gbp5f2dab arm64 [installed]
php7.4/buster,now 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 all [installed]

Thanks for your help !
CraftMarine.

Small update. When I move the config.php file, it seems to work

After remaking the file, everything work until I add ‘installed’ => true,

I have no clue on how to solve this.

Please post the output of php -m. This command does list all the induvidual modules not just the Debian packages. Most likely session and openssl are already installed. You can also check the output of php -i | grep -i openssl and php -i | grep -i session

[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

I tried to reinstall everything in PHP 8.1 and update manually nextcloud, I still face the same issue. Internal server error. It’s only when I remove the config.php (or the ‘installed’ => true,) it start “working” again.

just wanted to make sure that all the required PHP modules are installed, which seems to be the case.

Maybe you could also post the config.php that causes the issue…

Sure, here it is :

<?php
$CONFIG = array (
  'instanceid' => 'secret',
  'passwordsalt' => 'secret',
  'overwrite.cli.url' => 'http://192.168.X.X',
  'htaccess.RewriteBase' => '/',
  'secret' => 'secret',
  'trusted_domains' =>
  array (
    0 => '192.168.X.X',
    1 => 'mydomain.fr',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.0',
  'dbname' => 'nextclouddb_user',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'secret',
  'installed' => true,
  'default_phone_region' => 'FR',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0,
    'dbindex' => 0,
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 1,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'updater.secret' => 'secret',
);

This is my original config.php file, I haven’t touched during the update. I made another one without the redis and memcache options.

Not sure if this causes the issue… But I noticed this line:

'version' => '24.0.0',

In your original post you say that you are using Nextcloud 23. So there should probably be a value like 23.0.X.X, You can find out the correct version number in the version.php file in your nextcloud directory.

cat /var/www/nextcloud/version.php

My bad, I didn’t precised wich version I updated.

I decided to manually update from version 23 to 24 by replacing the files. I just kept the config file and edited the version number.

I checked with the version.php file and set it up to 24.0.2.1 but nothing changed.

Update :
After setting the option ‘installed’ to false, I check some infos on the installation page.
I have a missing module. I installed php8.1-mysql then, set back ‘installed’ to true. I came on the update page.

I did the update page he started working. Once done, it tried to redirect me to the main page but it got stuck into an infinite redirect loop.

I restarted the apache2 service, refreshed the page, came back to the original issue “Internal Server Error”. It would be nice if there was a way to tell what is causing this to make the error 500.

I tried to edit the config.php a bit more and removed all the redis and memcache options. It seems like it work better ? I don’t have the error 500 message but it keep looping on the login page. (refresh on refresh)

When I go into a cached logged account, it just loop too and I have this message in apache error.log :
[Tue Jun 28 10:16:53.676510 2022] [php:error] [pid 2988] [client my_IP:port] script ‘/var/www/nextcloud/apps/files/index.php’ not found or unable to stat, referer: https://mydomain.fr/apps/files/index.php

Whenever I create an empty “index.php” in the directory it stop looping and I get a blank page. (The login page still boot)

At this point I consider reinstalling everything.

Edit : I can download files without issues with the windows desktop client

Oh I overlooked that. And now that you mention it, the Redis module is not in your list either…

Here the list from my working installation. (You probably don’t need all of them but it shouldn’t hurt to have them either… :wink: )

[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imagick
intl
json
ldap
libsmbclient
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
smbclient
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

I use the PHP setup from this tutorial btw…

https://www.c-rieger.de/nextcloud-installationsanleitung-apache2-fast-track/

…which includes the following packages:

apt install libapache2-mod-php8.1 php-common php8.1-{fpm,gd,curl,xml,zip,intl,mbstring,bz2,ldap,apcu,bcmath,gmp,imagick,igbinary,mysql,redis,smbclient,cli,common,opcache,readline}
3 Likes

Thanks for this list, I had some missing modules.

Intersting enough, I still have the redirection loop issue. However, when I connect localy with the IP address and not the public FQDN, it does work fine.

somewhere a .htaccess not working properly ? I didn’t touched my virtual host in the apache config.

It was the .htaccess on the root of nextcloud directory. My instance is now back on track, need to tune some parameters.

Thanks you a lot bb77 for helping me with the modules issues.

For people coming for a similar issues, check with the list modules in this post.

1 Like