You are not logged in.

#1 2023-09-07 03:58:45

drankinatty
Member
From: Nacogdoches, Texas
Registered: 2009-04-24
Posts: 70
Website

Nextcloud new install. works w/o cache, breaks w/APCu or Redis or both

[SOLVED] - Solution at end of comment #7.

This is a strange issue where either something in nextcloud or something in the wiki isn't correct. I have a brand new install of nextcloud with php-legacy, and everything works until I try and enable caching. (Archlinux: 6.4.12-arch1-1 Apache/2.4.57 (Unix) OpenSSL/3.1.2 mod_fcgid/2.3.9 PHP/8.1.23) I have been through Nextcloud 8 - In memory caching with a fine-toothed comb. I've tried with APCu, I've tried with Redis, I've tried with both and as soon as any of the cache schemes is enabled, nextclould quits working with:

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'm not sure everything is logged, as my php-legacy log over the past 4 hours is sparse and doesn't look that informative, e.g.

2023-09-06T22:18:48-0500 -: "PROPFIND /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 90.674 6144 88.23%
2023-09-06T22:18:48-0500 -: "PROPFIND /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 128.536 6144 85.58%
2023-09-06T22:18:48-0500 -: "PROPFIND /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 119.930 6144 83.38%
2023-09-06T22:18:48-0500 -: "REPORT /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 105.556 6144 85.26%
2023-09-06T22:18:48-0500 -: "REPORT /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 92.133 6144 97.68%
2023-09-06T22:18:48-0500 -: "REPORT /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 93.395 6144 85.66%
2023-09-06T22:18:48-0500 -: "REPORT /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 84.328 6144 94.87%
2023-09-06T22:18:48-0500 -: "REPORT /nextcloud/remote.php" 207 //usr/share/webapps/nextcloud/remote.php 98.636 6144 91.24%
2023-09-06T22:19:17-0500 -: "GET /nextcloud/ocs/v2.php" 304 //usr/share/webapps/nextcloud/ocs/v2.php 104.364 6144 86.24%
2023-09-06T22:19:47-0500 -: "GET /nextcloud/ocs/v2.php" 304 //usr/share/webapps/nextcloud/ocs/v2.php 114.231 6144 78.79%
2023-09-06T22:20:17-0500 -: "GET /nextcloud/ocs/v2.php" 304 //usr/share/webapps/nextcloud/ocs/v2.php 105.431 4096 104.33%
2023-09-06T22:20:47-0500 -: "GET /nextcloud/ocs/v2.php" 304 //usr/share/webapps/nextcloud/ocs/v2.php 103.892 4096 105.88%
2023-09-06T22:21:17-0500 -: "GET /nextcloud/ocs/v2.php" 304 //usr/share/webapps/nextcloud/ocs/v2.php 117.347 4096 93.74%
2023-09-06T22:21:47-0500 -: "GET /nextcloud/ocs/v2.php" 304 //usr/share/webapps/nextcloud/ocs/v2.php 104.103 4096 96.06%
2023-09-06T22:22:05-0500 -: "PUT /nextcloud/ocs/v2.php?format=json" 200 //usr/share/webapps/nextcloud/ocs/v2.php 107.596 6144 92.94%
2023-09-06T22:22:05-0500 -: "PUT /nextcloud/ocs/v2.php?format=json" 200 //usr/share/webapps/nextcloud/ocs/v2.php 103.581 6144 77.23%
2023-09-06T22:22:17-0500 -: "GET /nextcloud/ocs/v2.php" 304 //usr/share/webapps/nextcloud/ocs/v2.php 104.525 4096 105.24%

This covers the time when it works and when each cache app was configured and tried separately and in combination.

The only thing odd in the wiki is in the Redis config, it contains:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
     'host'     => '/run/redis/redis.sock',
     'port'     => 0,
     'dbindex'  => 0,
     'password' => '',
     'timeout'  => 1.5,
],

The odd part is the 1st line -- that's the config for APCu not Redis according to Nextcloud Memory caching. I tried it as APCu and Redis, but it made no difference. (I presume the config in the wiki expects both to be configured and using APCu for memcache.local. The result with no APCu but with Redis with the wiki config is:

[Wed Sep 06 22:00:46.536601 2023] [mpm_prefork:notice] [pid 148753] AH00163: Apache/2.4.57 (Unix) OpenSSL/3.1.2 mod_fcgid/2.3.9 PHP/8.1.23 configured -- resuming normal operations
[Wed Sep 06 22:00:46.536682 2023] [core:notice] [pid 148753] AH00094: Command line: '/usr/bin/httpd -D FOREGROUND'
[Wed Sep 06 22:00:56.122642 2023] [proxy_fcgi:error] [pid 148757] [client 192.168.6.104:49228] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught OCP\\HintException: [0]: Memcache \\OC\\Memcache\\APCu not available for local cache (Is the matching PHP module installed and enabled?)\n\n  thrown in /usr/share/webapps/nextcloud/lib/private/Memcache/Factory.php on line 90'
[Wed Sep 06 22:00:56.122636 2023] [proxy_fcgi:error] [pid 148758] [client 192.168.6.104:49232] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught OCP\\HintException: [0]: Memcache \\OC\\Memcache\\APCu not available for local cache (Is the matching PHP module installed and enabled?)\n\n  thrown in /usr/share/webapps/nextcloud/lib/private/Memcache/Factory.php on line 90'

The nextcloud.log contains nothing useful other than:

{"reqId":"TuFO7ny6RratByEvEg14","level":3,"time":"2023-09-07T03:18:48+00:00","remoteAddr":"192.168.6.104","user":"david","app":"PHP","method":"REPORT","url":"/nextcloud/remote.php/dav/calendars/david/tasks/","message":"Module \"bcmath\" is already loaded at Unknown#0","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0","version":"27.0.2.1","data":{"app":"PHP"}}

My config for /etc/webapps/nextcloud/config/config.php is:

  /* 'memcache.local' => '\OC\Memcache\APCu', */
  /* 'memcache.local' => '\OC\Memcache\Redis',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => [
     'host'     => '/run/redis/redis.sock',
     'port'     => 0,
     'dbindex'  => 0,
     'password' => '',
     'timeout'  => 1.5,
  ], */

first line uncommented with lines 3-end for APCu config and Both. Second line - end is used for Redis alone..

In /etc/php-legacy/php-fpm.d/nextcloud.conf I uncomment:

; uncomment if php-apcu is installed and used
; php_value[extension] = apcu

; uncomment for redis
; php_value[extension] = igbinary
; php_value[extension] = redis

For /etc/webapps/nextcloud/php.ini I uncomment for redis:

; extension=redis
; extension=igbinary

and for APCu:

; APCu cache for nextcloud
;
;extension=apcu
;apc.ttl=7200
;apc.enable_cli = 1

added at end.

I even manually created /run/redis and did gpasswd -a nextcloud http and chown nextcloud:http /run/redis and chmod 0770 /run/redis but redis.sock is never created.

So I'm stuck. Nextcloud works beautifully as long as I don't enable cache, but as soon as I do, it crashes. As soon as I disable cache, it works again. All other php sites continue to work normally no matter what -- so this is a nextcloud issue.

Help?

Last edited by drankinatty (2023-10-06 06:09:38)


David C. Rankin, J.D.,P.E.

Offline

#2 2023-09-07 09:45:52

drankinatty
Member
From: Nacogdoches, Texas
Registered: 2009-04-24
Posts: 70
Website

Re: Nextcloud new install. works w/o cache, breaks w/APCu or Redis or both

If we have any German speakers, This Nextcloud Document addresses the APCu cache problem and the .well-known/xxx link issue.

It will take me a bit longer to work through it. But with the new PHP8.1 and Nextcloud 27, there are changes to the server SSL config to address the .well-known/xxx problem and several other config settings needed for the APCu cache that will need to be added to the wiki.


David C. Rankin, J.D.,P.E.

Offline

#3 2023-09-07 20:32:13

drankinatty
Member
From: Nacogdoches, Texas
Registered: 2009-04-24
Posts: 70
Website

Re: Nextcloud new install. works w/o cache, breaks w/APCu or Redis or both

I have been working this with Nextcloud as well. For those interested, the Nextcloud forum thread is New Install 27.0.2 on PHP8.1 Archlinux, APCu fails, .well-known warnings.


David C. Rankin, J.D.,P.E.

Offline

#4 2023-09-07 22:58:26

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: Nextcloud new install. works w/o cache, breaks w/APCu or Redis or both

Please stop multiposting. If you are the last person to post in a thread, and you have something to add, please use the edit button to amend the last post.

Offline

#5 2023-09-08 05:49:24

drankinatty
Member
From: Nacogdoches, Texas
Registered: 2009-04-24
Posts: 70
Website

Re: Nextcloud new install. works w/o cache, breaks w/APCu or Redis or both

2ManyDogs wrote:

Please stop multiposting. If you are the last person to post in a thread, and you have something to add, please use the edit button to amend the last post.

Many apologies, will do. I wasn't aware.

This issue is a true problem. I can enable APCu in the pool php-fpm.ini and confirm APCu is enabled with php phpinfo(); and nextcloud still fails to see that the module is enable. apc.enable_cli = 1 was included in the pool ini as well. No change.


David C. Rankin, J.D.,P.E.

Offline

#6 2023-09-10 19:27:30

kde35
Member
Registered: 2015-04-13
Posts: 71

Re: Nextcloud new install. works w/o cache, breaks w/APCu or Redis or both

drankinatty wrote:
2ManyDogs wrote:

Please stop multiposting. If you are the last person to post in a thread, and you have something to add, please use the edit button to amend the last post.

Many apologies, will do. I wasn't aware.

This issue is a true problem. I can enable APCu in the pool php-fpm.ini and confirm APCu is enabled with php phpinfo(); and nextcloud still fails to see that the module is enable. apc.enable_cli = 1 was included in the pool ini as well. No change.

I have had similar problem, now I have /etc/php/conf.d/apcu.ini with

;extension=apcu.so
apc.enabled=1
apc.shm_size=32M
apc.ttl=7200
apc.enable_cli=1

(the line withe extesion is commented because it is already enabled in /etc/php/php.ini, remainder from the old configuration), and apcu works.

However, I have been able to use redis so far.

Offline

#7 2023-09-14 08:35:20

drankinatty
Member
From: Nacogdoches, Texas
Registered: 2009-04-24
Posts: 70
Website

Re: Nextcloud new install. works w/o cache, breaks w/APCu or Redis or both

kde35 wrote:

I have had similar problem, now I have /etc/php/conf.d/apcu.ini with

;extension=apcu.so
apc.enabled=1
apc.shm_size=32M
apc.ttl=7200
apc.enable_cli=1

(the line withe extesion is commented because it is already enabled in /etc/php/php.ini, remainder from the old configuration), and apcu works.

Thanks for the reply, but unfortunately, re-enabling all APCu settings as shown in the wiki, and adding your suggestions in abcu.ini nextcloud still fails with the same 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.

There is nothing in the httpd/error log and the only thing in the php-fpm-legacy/access/nextcloud.log is

2023-09-14T03:22:03-0500 -: "GET /nextcloud/index.php" 500 //usr/share/webapps/nextcloud/index.php 12.976 2048 77.07%

The nextcloud.log log contains nothing. This is a nextcloud error as eGroupware running on the same server (and all other php apps) continue working just fine with APCu enabled in the main php-legacy/php.ini:

; nextcloud APCu test
extension=apcu
apc.ttl=7200
apc.enable_cli = 1

It is this line added to /etc/webapps/nextcloud/config/config.php that causes nextcloud to break:

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

I can leave the rest of the config for APCu enabled, but as soon as I add the line above, the internal server error happens immediately.

In fact I can have APCu, Redis and Igbinary fully configured as shown in the wiki except for adding any information to /etc/webapps/nextcloud/config/config.php. As soon as I add either of the suggested configurations shown below, the internal server error occurs immediately (additions show commented):

  /* 'memcache.local' => '\OC\Memcache\APCu', */
  /* 
    below for Redis alone
  */
  /*
  'memcache.local' => '\OC\Memcache\Redis',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => [
       'host'     => '/run/redis/redis.sock',
       'port'     => 0,
       'dbindex'  => 0,
       'password' => '',
       'timeout'  => 1.5,
  ],
  */

Any other ideas?

## Update

After upgrade to 27.1.1 APCu cache works now configured as above, but redis continues to invoke an Internal Server Error. So progress has been made.

## Update 2

After upgrade to php-legacy-redis-6.0.1-1, the problem of Internal Server Error when adding any part of the Redis config to /etc/webapps/nextcloud/config/config.php remains. Immediate Internal Server Error ... occurs as soon as the config is saved and either the cron task runs or another view is selected.

------> SOLVED <------

An unexpected php_value[open_basedir] setting was the culprit.

For this test box open_basedir was intentionally not enabled in any of my php.ini/php-fpm.ini files. However, it turns out that open_basedir is enabled by default in the Archlinux package in nextcloud.conf (/etc/php-legacy/php-fpm.d/nextcloud.conf as php_value[open_basedir] = ...). The setting is located well up above and away from where the wiki instructs you to add or uncomment the igbinary and redis extensions -- so not something you will be drawn to unless you are looking for it.

It was a stray grep of nextcloud.conf dumping it without comments that disclosed open_basedir being set as part of the webapp isolation. There are no errors or warnings generated from the missing path component in nextcloud.conf.

BINGO! Once the setting was discovered, simply adding /run/redis to the php_value[open_basedir] = ...:/run/redis path allowed full caching and the MySQL transactional locking to work like clockwork.

Last edited by drankinatty (2023-10-06 06:06:36)


David C. Rankin, J.D.,P.E.

Offline

Board footer

Powered by FluxBB