Redis will not work on ANY configuration on fresh install

Nextcloud version: 22.1.1
Operating system and version: CENTOS 7.9 with cPanel v98.0.7
Apache or nginx version: Apache/2.4.48 (cPanel)
PHP version: 7.4

The issue you are facing:

I’ve tried configuring Redis with NextCloud on a fresh install using the network interface and the Unix socket and neither of them have worked for me.

When I try to use Redis using the network interface (localhost or 127.0.0.1) on my config.php, I still get the “No memory cache has been configured” warning in my admin overview page.

I can confirm that Redis is installed and seems to be working fine:

root@server [~]# redis-cli
127.0.0.1:6379> ping
PONG

I can also confirm the Redis PHP extension is installed:

root@server [~]# php -m | grep redis
redis

This is the code I have added to my config.php:

  'memcache.distributed' => '\OC\Memcache\Redis',
  'redis' => [
     'host' => 'localhost',
     'port' => 6379,
    ],

It doesn’t seem to work. I still get the “No memory cache has been configured” warning in my admin overview page. I’ve also tried replacing ‘localhost’ with ‘127.0.0.1’ and also my server’s IP address, both to no avail. Worse still is that there are no errors I can see in my NextCloud log.

When I set my config.php to use the Unix socket instead, I did do the prerequisites of setting my port to 0 and uncommenting the unixsocket and unixsocketperm lines, and setting the unixsocketperm to 770 specifically in my redis.conf file:

port 0
unixsocket /var/run/redis/redis.sock
unixsocketperm 770

I also added the Apache user www-data (in my OS it’s just called “apache”) to the Redis group:

root@server [~]# sudo usermod -a -G redis apache
root@server [~]# sudo -u apache redis-cli -s /var/run/redis/redis.sock
redis /var/run/redis/redis.sock> ping
PONG

Then I added this code to my config.php:

  'memcache.distributed' => '\OC\Memcache\Redis',
  'redis' => [
     'host' => '/var/run/redis/redis.sock',
     'port' => 0,
  ],

Then I do a full server restart.

Still no dice, and this time, I get an error when opening my NextCloud page:

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.

When, removing the lines I added in my config.php, NextCloud does work again though and fortunately, this time, there are errors in the log:

NextCloud.log - Pastebin.com

Can anyone tell me what this means? I found a thread where someone was facing a similar issue, except in their case, it turned out to be a SELinux issue, but unfortunately in my server SELinux is turned off entirely:

Cannot get Redis with Unix socket to work on Centos 8 Stream - :information_source: Support - Nextcloud community

Hopefully that may give a clue but at this point, I have no idea, and I’m new to using Redis. This is a fresh install, and besides the changes I have stated above, all the other settings for my config.php and redis.conf are the default ones.

Can you confirm how you turned SELinux off entirely?

For Redis over a TCP socket did you also enable memcache.local? That is your config.php would look like this:

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

I think you need memcache.local setup (APCu or Redis) to get rid of the “No memory cache has been configured” error. Just having memcache.distributed will not work. Please correct me if I am wrong.

As for the Redis over a Unix Socket it looks like something is blocking Nextcloud/PHP for accessing /var/run/redis/redis.sock on the file system. If it is not SELinux I would double check what uses PHP-FPM is running as. I have not used cPanel before, so I am not sure what they do for this. I would check how you Apache config is accessing PHP (TCP or Unix Socket) and traces this back to an PHP-FMP pool, i.e one of the configs in php-fpm.d. Check if it is assigned to listen as a different user.

I hope this helps

1 Like

In regard to SELinux, it was not the first time someone recommended configuring it in order to fix the connection issue over the Unix socket. However, any command I run relating to SELinux, always returns the same output, even the command you ran when you faced a similar issue:

root@server [~]# sudo setenforce 0
setenforce: SELinux is disabled

So I assume this means that SELinux is disabled on my server. Regardless though, the Unix connection issue does not resolve even when I run this command. Though I have to admit that I am not familiar with SELinux and I do not know how to verify if it is completely off.

For Redis over a TCP socket you were completely correct. Enabling memcache.local fixed the issue(though I opted for APCu instead of Redis as I’ve read it is faster, I don’t know if that’s still true), and the “No memory cache has been configured" warning in my admin overview page went away. I can’t believe I overlooked this, thank you so much!

I guess the next step would be getting the Unix socket to work. I do not know what is blocking Nextcloud/PHP from accessing /var/run/redis/redis.sock on the file system. However, PHP-FPM is disabled on my system because I opted to use LSAPI instead which requires me to disable the former.

So on my system, LSAPI is used as the PHP handler. Don’t know if that helps.

This is the first time I have heard about LSAPI, so I don’t think I can be much of a help here.

The first thing I would double-check is that Nextcloud is in fact running as the apache uses. Try doing a ls -l on your nextcloud.log file or anything in your data directory. My apologies if you have ruled this out, but sometimes it’s good to check the basis first.

Other than that, I would check if LSAPI has some access control or security mechanism that limits access to the file system.

Cheers