How to setup redis cache on php 8.1?

Hi, so my system is:
VPS: ARM64, 4cpu/8GB RAM
Ubuntu 22. Installed NC via Hestia CP. Running on PHP 8.1. Could someone help me, with how to set up the Redis cache? Thanks.
Redis is running successfully on my WordPress sites.

It’s in the docs:

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html#organizations-with-single-server

It sounds like you’ll probably already have the PHP redis extension installed and enabled in your PHP if you’re already using it. So it’s just a matter of configuring your Nextcloud instance to use it in your config.php by adding/adjusting as follows:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
     'host' => 'localhost',
     'port' => 6379,
],
1 Like

for little more performance you also could use the unix sock

nextcloud config.php like this

  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/PATH/TO/YOUR/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'timeout' => 1.5,
  ),

:grinning:

In my case path is
/var/run/redis/redis.sock

but also could be
/var/run/redis/redis-server.sock

1 Like

yes, but I getting 500 internal error

concerning “redis” ?
Have you tried to set up config.php without redis (just APCU) and then restart of webserver for NC
Does the 500 internal error occur again?

All php modules installed?
All redis services
→ redis.service
→ redis-sentinel.service
are up and running?

redis connectable via … ??

a) socket
redis-cli -s /var/run/redis/redis.sock

b)
redis-cli -h 127.0.0.1 -p 6379

WordPress sees Redis cache, so thinking that all modules are running. Connecting Redis via port 6379.

Solved:
‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘filelocking.enabled’ => ‘true’,
‘redis’ =>
array (
‘host’ => ‘127.0.0.1’,
‘port’ => 6379,
‘timeout’ => 0.0,
‘password’ => ‘mypass’,
),
);

2 Likes

For future reference, when you get 500 errors with Nextcloud, the answer will always be in your nextcloud.log located in your NC datadirectory. That’s the place to start when troubleshooting.

1 Like