Internal Server Error when enabling APCu or redis

:slight_smile: /details]

Nextcloud version (eg, 20.0.5): 26.0.0.11
Operating system and version (eg, Ubuntu 20.04): Debian GNU/Linux 11 (bullseye)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.56 (Debian)
PHP version (eg, 7.4): PHP 8.2.4 and 8.1

The issue you are facing:
I am trying to enable memcaching using APCu and redis. I followed the docs and ensured to apt install php-apcu and apt install redis-server and did setup redis setup correctly. When I add the lines to config.php:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',

then systemctl restart apache, I get an Internal Server Error on the webpage.

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

Steps to replicate it:

  1. Add the lines above to config.php
  2. run systemctl restart apache2

The output of your Nextcloud log in Admin > Logging:

This same error repeats hundreds of times, so I’ll just past 1 line

Error	webdav	TypeError: OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/MYDOMAIN/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263		2023-04-04T15:00:12-0500

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

<?php
$CONFIG = array (
  'instanceid' => 'CENSORED',
  'passwordsalt' => 'CENSORED',
  'secret' => 'CENSORED',
  'trusted_domains' =>
  array (
    0 => 'CENSORED',
    1 => 'CENSORED',
  ),
  'datadirectory' => '/media/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '26.0.0.11',
  'overwrite.cli.url' => 'CENSORED',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'CENSORED',
  'dbpassword' => 'CENSORED',
  'installed' => true,
  'config_is_read_only' => false,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.secret' => 'CENSORED',
  'skeletondirectory' => 'CENSORED',
  'defaultapp' => 'files',
  'trashbin_retention_obligation' => 'auto',
  'enable_previews' => false,
);

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

Syslog only has entries from a few days ago, April 2, and not from today, April 4th, when I was having the issue

Apache Error Log

[Tue Apr 04 00:00:01.751251 2023] [mpm_event:notice] [pid 696:tid 139856828685632] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 00:00:01.751278 2023] [core:notice] [pid 696:tid 139856828685632] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:31:46.291263 2023] [mpm_event:notice] [pid 696:tid 139856828685632] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:31:49.651456 2023] [core:warn] [pid 696:tid 139856828685632] AH00045: child process 69483 still did not exit, sending a SIGTERM
[Tue Apr 04 13:31:49.651510 2023] [core:warn] [pid 696:tid 139856828685632] AH00045: child process 69339 still did not exit, sending a SIGTERM
[Tue Apr 04 13:31:51.653787 2023] [core:warn] [pid 696:tid 139856828685632] AH00045: child process 69483 still did not exit, sending a SIGTERM
[Tue Apr 04 13:31:51.653868 2023] [core:warn] [pid 696:tid 139856828685632] AH00045: child process 69339 still did not exit, sending a SIGTERM
[Tue Apr 04 13:31:53.656004 2023] [core:warn] [pid 696:tid 139856828685632] AH00045: child process 69483 still did not exit, sending a SIGTERM
[Tue Apr 04 13:31:53.656063 2023] [core:warn] [pid 696:tid 139856828685632] AH00045: child process 69339 still did not exit, sending a SIGTERM
[Tue Apr 04 13:31:55.658239 2023] [core:error] [pid 696:tid 139856828685632] AH00046: child process 69483 still did not exit, sending a SIGKILL
[Tue Apr 04 13:31:55.658320 2023] [core:error] [pid 696:tid 139856828685632] AH00046: child process 69339 still did not exit, sending a SIGKILL
[Tue Apr 04 13:31:56.820235 2023] [mpm_event:notice] [pid 69590:tid 139701597056320] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:31:56.820279 2023] [core:notice] [pid 69590:tid 139701597056320] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:32:07.663517 2023] [mpm_event:notice] [pid 69590:tid 139701597056320] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:32:11.023802 2023] [core:warn] [pid 69590:tid 139701597056320] AH00045: child process 69591 still did not exit, sending a SIGTERM
[Tue Apr 04 13:32:13.026107 2023] [core:warn] [pid 69590:tid 139701597056320] AH00045: child process 69591 still did not exit, sending a SIGTERM
[Tue Apr 04 13:32:15.028402 2023] [core:warn] [pid 69590:tid 139701597056320] AH00045: child process 69591 still did not exit, sending a SIGTERM
[Tue Apr 04 13:32:17.030725 2023] [core:error] [pid 69590:tid 139701597056320] AH00046: child process 69591 still did not exit, sending a SIGKILL
[Tue Apr 04 13:36:25.400559 2023] [mpm_event:notice] [pid 69683:tid 139632111729984] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:36:25.400637 2023] [core:notice] [pid 69683:tid 139632111729984] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:38:38.443948 2023] [mpm_event:notice] [pid 69683:tid 139632111729984] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:38:38.510769 2023] [mpm_event:notice] [pid 69757:tid 139974985637184] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:38:38.510939 2023] [core:notice] [pid 69757:tid 139974985637184] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:40:19.041182 2023] [mpm_event:notice] [pid 69757:tid 139974985637184] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:40:19.199551 2023] [mpm_event:notice] [pid 69948:tid 140082275040576] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:40:19.199693 2023] [core:notice] [pid 69948:tid 140082275040576] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:47:03.019342 2023] [mpm_event:notice] [pid 69948:tid 140082275040576] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:47:03.236803 2023] [mpm_event:notice] [pid 70037:tid 140469469703488] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:47:03.236978 2023] [core:notice] [pid 70037:tid 140469469703488] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:47:52.247820 2023] [mpm_event:notice] [pid 70037:tid 140469469703488] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:47:52.310170 2023] [mpm_event:notice] [pid 70109:tid 139816764263744] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:47:52.310306 2023] [core:notice] [pid 70109:tid 139816764263744] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:51:10.925512 2023] [mpm_event:notice] [pid 70109:tid 139816764263744] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:51:11.015239 2023] [mpm_event:notice] [pid 70206:tid 139767985012032] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:51:11.015439 2023] [core:notice] [pid 70206:tid 139767985012032] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 13:55:31.025572 2023] [mpm_event:notice] [pid 70206:tid 139767985012032] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 13:55:33.449424 2023] [mpm_event:notice] [pid 70294:tid 140063647448384] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 13:55:33.449570 2023] [core:notice] [pid 70294:tid 140063647448384] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 14:20:48.997130 2023] [mpm_event:notice] [pid 70294:tid 140063647448384] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 14:20:52.357078 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71793 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:52.357124 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71861 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:52.357138 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71107 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:52.357150 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71204 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:54.359338 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71793 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:54.359380 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71861 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:54.359408 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71107 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:54.359419 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71204 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:56.361613 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71793 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:56.361655 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71861 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:56.361668 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71107 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:56.361680 2023] [core:warn] [pid 70294:tid 140063647448384] AH00045: child process 71204 still did not exit, sending a SIGTERM
[Tue Apr 04 14:20:58.363862 2023] [core:error] [pid 70294:tid 140063647448384] AH00046: child process 71793 still did not exit, sending a SIGKILL
[Tue Apr 04 14:20:58.363924 2023] [core:error] [pid 70294:tid 140063647448384] AH00046: child process 71861 still did not exit, sending a SIGKILL
[Tue Apr 04 14:20:58.363983 2023] [core:error] [pid 70294:tid 140063647448384] AH00046: child process 71107 still did not exit, sending a SIGKILL
[Tue Apr 04 14:20:58.364027 2023] [core:error] [pid 70294:tid 140063647448384] AH00046: child process 71204 still did not exit, sending a SIGKILL
[Tue Apr 04 14:20:59.465286 2023] [mpm_event:notice] [pid 71996:tid 139635667578176] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 14:20:59.465443 2023] [core:notice] [pid 71996:tid 139635667578176] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 14:22:24.616312 2023] [mpm_event:notice] [pid 71996:tid 139635667578176] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 14:22:27.976911 2023] [core:warn] [pid 71996:tid 139635667578176] AH00045: child process 71997 still did not exit, sending a SIGTERM
[Tue Apr 04 14:22:27.976976 2023] [core:warn] [pid 71996:tid 139635667578176] AH00045: child process 71998 still did not exit, sending a SIGTERM
[Tue Apr 04 14:22:29.979303 2023] [core:warn] [pid 71996:tid 139635667578176] AH00045: child process 71997 still did not exit, sending a SIGTERM
[Tue Apr 04 14:22:29.979406 2023] [core:warn] [pid 71996:tid 139635667578176] AH00045: child process 71998 still did not exit, sending a SIGTERM
[Tue Apr 04 14:22:31.981742 2023] [core:warn] [pid 71996:tid 139635667578176] AH00045: child process 71997 still did not exit, sending a SIGTERM
[Tue Apr 04 14:22:31.981832 2023] [core:warn] [pid 71996:tid 139635667578176] AH00045: child process 71998 still did not exit, sending a SIGTERM
[Tue Apr 04 14:22:33.984205 2023] [core:error] [pid 71996:tid 139635667578176] AH00046: child process 71997 still did not exit, sending a SIGKILL
[Tue Apr 04 14:22:33.984313 2023] [core:error] [pid 71996:tid 139635667578176] AH00046: child process 71998 still did not exit, sending a SIGKILL
[Tue Apr 04 14:22:35.109484 2023] [mpm_event:notice] [pid 72078:tid 140556707704128] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 14:22:35.109643 2023] [core:notice] [pid 72078:tid 140556707704128] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 14:54:12.819396 2023] [mpm_event:notice] [pid 72078:tid 140556707704128] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 14:54:16.179013 2023] [core:warn] [pid 72078:tid 140556707704128] AH00045: child process 73564 still did not exit, sending a SIGTERM
[Tue Apr 04 14:54:16.179103 2023] [core:warn] [pid 72078:tid 140556707704128] AH00045: child process 73435 still did not exit, sending a SIGTERM
[Tue Apr 04 14:54:18.181402 2023] [core:warn] [pid 72078:tid 140556707704128] AH00045: child process 73564 still did not exit, sending a SIGTERM
[Tue Apr 04 14:54:18.181449 2023] [core:warn] [pid 72078:tid 140556707704128] AH00045: child process 73435 still did not exit, sending a SIGTERM
[Tue Apr 04 14:54:20.183721 2023] [core:warn] [pid 72078:tid 140556707704128] AH00045: child process 73564 still did not exit, sending a SIGTERM
[Tue Apr 04 14:54:20.183799 2023] [core:warn] [pid 72078:tid 140556707704128] AH00045: child process 73435 still did not exit, sending a SIGTERM
[Tue Apr 04 14:54:22.186157 2023] [core:error] [pid 72078:tid 140556707704128] AH00046: child process 73435 still did not exit, sending a SIGKILL
[Tue Apr 04 14:54:23.288553 2023] [mpm_event:notice] [pid 73641:tid 140360981278016] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 14:54:23.288699 2023] [core:notice] [pid 73641:tid 140360981278016] AH00094: Command line: '/usr/sbin/apache2'
[Tue Apr 04 14:54:49.768560 2023] [mpm_event:notice] [pid 73641:tid 140360981278016] AH00492: caught SIGWINCH, shutting down gracefully
[Tue Apr 04 14:54:53.128748 2023] [core:warn] [pid 73641:tid 140360981278016] AH00045: child process 73644 still did not exit, sending a SIGTERM
[Tue Apr 04 14:54:54.179844 2023] [mpm_event:notice] [pid 73713:tid 140432286207296] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Tue Apr 04 14:54:54.179986 2023] [core:notice] [pid 73713:tid 140432286207296] AH00094: Command line: '/usr/sbin/apache2'

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.

Will not post, contains sensitive user IPs. Ask if looking for anything specific and I can provide as necessary

Regarding this error, see Need help with docker install Nextcloud 26.0.0 .

I’m not running nextcloud in a docker. It’s installed on a Debian VM.

Did you look at/read the thread I suggested? It’s irrelevant whether you run it in Docker or not. No need to assume that this is what we’re talking about just because the other poster happens to run it in Docker.

I’m dumb. I should’ve read lol I complain how people don’t read and here I am not reading. My bad. Give me some time to read through

2 Likes

So I see there was no solution in the thread you shared. I did look into the github and searching through, but so far don’t see anything that’s specific to my issue or related to the DAV error. But this would explain why some of my users are reporting missing files. But that is a separate issue of the internal server error when enabling memcaching

You only need one php version and I would always advice, to totally remove all not used and not needed php-versions and modules. as well as any meta-packages. It is a common source of plenty of errors.

did you add where nextcloud have to talk to redis, like this (example):

  'redis' => 
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0,
  ),

did you start the redis server?

You can live see what redis does with redis-cli:

redis-cli -s /var/run/redis/redis-server.sock monitor

Here you’ll find the redis-cli manual: https://redis.io/docs/connect/cli/

I only installed 8.1, but when I installed various php modules, 8.2 was automatically installed. If I remove 8.1, nextcloud does not run at all. I’ve only ever been able to get it work with both version installed.

I’ve not yet defined where nextcloud talks to redis, nextcloud docs are a bit obscure to me. However, even when just adding the APCu line, I get the same issue. I will add the necessary info for redis and try again.

So how can I disable DAV? I’ve been looking and don’t see this app anywhere.

I’m not sure you can, it’s one of the core/default apps. One could look into the database or just use occ to see if you can list and then disable that specific app. But I’m not sure if Nextcloud would be happy about it :slight_smile:

That’s botch. You should solve that.
Normaly by totaly removing php8.2:

First switch everything by hand to the 8.1

for linkgroup in `ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"`; do update-alternatives --config $linkgroup; done

and when you see, that everything is running well, you can totaly remove the not used php8.2:

sudo apt-get remove --purge php8.2*

Thats crucial, since redis is a server at its own. It needs good fine tuning and you should observe it thorowly at the beginning.

As well, you have to add some lines to the php.ini as described here

1 Like

Any reason why I would be getting Internal server error when just simply enabling APCu though? I followed the docs here.

Since APCu is a php module, it could be caused by version confusion I described above.

Are you using php-fpm?

Yea, I believe that’s what uses PHP 8.2.

Nextcloud’s docs are pretty over-complex so I had to rely on googling install guides and what not and trial and error a lot of it, supplemented by the official docs. I ended up making my own guide to fall back on, but I’m sure it’s also not as reliable since it’s pieced together from other various unofficial sources. I’ve been trying to better understand and tune my server and get it performing at its best.

So I did run that command and this is what was returned:

myUser#  for linkgroup in `ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"`; do update-alternatives --config $linkgroup; done
There are 3 choices for the alternative phar (providing /usr/bin/phar).

  Selection    Path                   Priority   Status
------------------------------------------------------------
* 0            /usr/bin/phar.default   100       auto mode
  1            /usr/bin/phar.default   100       manual mode
  2            /usr/bin/phar8.1        81        manual mode
  3            /usr/bin/phar8.2        82        manual mode

Press <enter> to keep the current choice[*], or type selection number:

I’m not sure what any part of that command is meant to do. I know enough linux to mostly do what I need to lol

Read the man page thoroughly until you understand:

man update-alternatives

In this specific case, you should enter “2”, to select the 8.1 Version to be the one you use.

So I selected 2, then ran apt-get remove --purge php8.1 and it returned:

root@v4:/home/luck# apt-get remove --purge php8.2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'php8.2' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Still says php version is 8.2.4

PHP 8.2.4 (cli) (built: Mar 16 2023 14:37:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.4, Copyright (c), by Zend Technologies

Do I need to delete the 8.2 directory from /etc/php?

I see only on this 2 lines, that you do lots of things verry chaotic.

In the first line you writh 8.1 but in the echo of the console it is 8.2

I wrote something totally diferent: 8.2*

That one * is a so called wildcard for whatever you want. 8.2 is ONLY for php8.2 and php8.2* is for all packeges where the name begins with php8.2

But you should not yet uninstall, before you tried if everything is running smooth.

1 Like

Excuse me, this was chaos from my side, I wrote it wrong.

So now again, this is the correct command:

sudo apt-get remove --purge php8.2*

Some updates:

I’ve managed to get APCu working correctly. It had escaped my mind to do apt install php8.1-apcu instead of apt install php-apcu as the latter installed the 8.2 version, which doesn’t work. After purging all of the php8.2 related packages, I went and reinstalled all the other required php mods using php8.1- and that has worked out well.

I’ve since been working on getting redis working for distributed caching and file locking. So far, I have doubled my performance.

Thank you everyone that has responded as all of your responses have lead me to where I am now. Cheers!

2 Likes