Nextcloud und redis (memcache.local / memcache.locking)

riegerCLOUD: Unter Ubuntu 16.04 LTS können Sie den REDIS-Server durch apt-get install einfach installieren und mit nur sehr wenigen Konfigurationen für ihre nextcloud einrichten.

Installation von REDIS für nextcloud

Viel Spaß, Carsten

The new URL: https://www.c-rieger.de/nextcloud-installation-guide/#c04

2 Likes

I’ll venture to translate the post…

If your server runs Ubuntu 16.04 LTS you can install the REDIS Server easily using “apt-get install”. Only very few configuration settings are required to set it up for your nextcloud.

Start the installtion with
sudo -s apt install redis-server php-redis

afterwards edit file
vi /etc/redis/redis.conf

and change
a) the default port to 0:
# port 6379 port 0

and b) two unix socket entries
unixsocket /var/run/redis/redis.sock unixsocketperm 770

save and exit the file (“wq!”) and grant your php-user the rights required
usermod -a -G redis www-data

Now, start the redis server:
service redis-server start

and with
ls -la /run/redis

check for the existance of files
redis-server.pid redis.sock

If you fail to find the files rght away restart your raspberry and check again.

At last modify the nextcloud config with
sudo -u www-data vi /var/www/owncloud/config/config.php

by adding the following lines:
... 'memcache.local' => '\OC\Memcache\APCu', 'filelocking.enabled' => 'true', 'memcache.locking' => '\\OC\\Memcache\\Redis', 'redis' => array ( 'host' => '/var/run/redis/redis.sock', 'port' => 0, 'timeout' => 0.0, ), ...

and enjoy the new caching for your nextcloud :slight_smile:

5 Likes

perfect - thx
next time i will post it in the forum in english from the beginning

I could not get any other methods of data caching to work, but this one did. Thanks!

1 Like

Yeah, I tried setting up redis for file locking following the official documentation before and it caused strange errors, but now following this it seems to have done the trick. Maybe someone can transfer this to the official documentation?

great!
my “nextcloud installation guide” is available in version 8.3 and written in english
=> nextcloud installation guide (oDroid C2/RPi3)

3 Likes

welll This didnt work either … all I got was a white screen after doing this. Similar to the other guides I have tried

For further support please post your
(1) nextcloud/config/config.php
and your
(2) /etc/redis/redis.conf

Did you doublecheck this: Redis - Installation/Configuration ?

Cheers, carsten

@riegerCLOUD Hello thanks for the reply I have the config.php and the redis.conf.

I went through that guide step by step and the redis seems to be installed fine… just for whatever reason its a white screen.

I think it has something to do with the config.php as it doesnt whie screen with that back to the original content.

My Nextcloud is installed in /var/www/nextcloud

My data is installed in /var/www/nextcloud/data

Htuser and htgroup are www-data

I do have HTTPS enabled and a redirect from example.com/nextcloud to just example.com

I did run the permissions script… although I did try this on a fresh install without the permissions script and stild did the same thing.

Config.php


<?php
$CONFIG = array (
  'instanceid' => 'ocxfw6mpi',
  'passwordsalt' => '+AL1TinfqwLFixVD0QPkgY',
  'secret' => 'KJCj1cl+N8qibETOSbOrbD7T07ei/HbRKod/FI',
  'trusted_domains' => 
  array (
    0 => 'site.com',
    1 => '192.xxx.x.xx',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'overwrite.cli.url' => 'https://localhost',
  'overwriteprotocal' => 'https'
  'dbtype' => 'mysql',
  'version' => '9.1.1.5',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'redacted',
  'logtimezone' => 'UTC',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
   'filelocking.enabled' => 'true',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
   array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
);

and the redis.conf

http://pastebin.com/hd52BRqB

There is no memcache enabled in config.php yet? Didn’t you install APCu?

‘memcache.local’ => ‘\OC\Memcache\APCu’,

Please enable and re-test it. If you still run in troubles please disable the redis part

‘filelocking.enabled’ => ‘true’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘/var/run/redis/redis.sock’,
‘port’ => 0,
‘timeout’ => 0.0,
),

what will happen?

Please also have a look in the nginx error.log, the nextcloud.log and the php.log.
Cheers, Carsten

@riegerCLOUD

Thanks again for the help

as far as APCu goes I am not sure. All I have done is follow the guides and I do no think that they mentioned APCu.
I have not installed it as I thought it was completely unrelated to redis.

The config.php … all I did there was pretty much copy and paste it into the config.php

are you saying that I need to install APCu or just possible add that line to config.php?

also to disable redis do I change the ‘filelocking.enabled’ =>‘true’ to ‘filelocking.enabled’ => ‘disabled’ ?

I usually try to find step by step guides on this stuff as I am not familiar with any kind of code … as you can probably tell.

also I did try this as well in the config.php

'memcache.local' => '\OC\Memcache\APCu',
'filelocking.enabled' => 'true',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => 
array (
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'timeout' => 0.0,
),

and same white screen

It will work without APCu but it is not recommended from Nextcloud perspective.
To check Nextcloud without REDIS remove the block

‘filelocking.enabled’ => ‘true’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘/var/run/redis/redis.sock’,
‘port’ => 0,
‘timeout’ => 0.0,
),

Does Nextcloud work as expected without having REDIS installed/configured?
What error messages are thrown?
In addition please press STRG+SHIFT+K or F12 in your firefox, call your nextcloud and look for errors too.

I never installed APCu, and I’ve been using ‘memcache.local’ => ‘\OC\Memcache\Redis’ for a while now. What’s the difference between that and APCu for local caching (why not just use Redis for all caching?)?

https://docs.nextcloud.com/server/10/admin_manual/configuration_server/caching_configuration.html?highlight=apcu

Thanks, it was in there the whole time, but I just missed it. https://docs.nextcloud.com/server/10/admin_manual/configuration_server/caching_configuration.html?highlight=apcu#additional-notes-for-redis-vs-apcu-on-memory-caching

Doesn’t work on our server, which is a Ubuntu Yakkety box with Nginx and PHP-fpm. What does kind of “works” (that is: it doesn’t throw an error, but it has no discernible effect either) is

'filelocking.enabled' => 'true',
'memcache.locking' => '\\OC\\Memcache\\Redis',
// 'memcache.local' => '\OC\Memcache\APCu',
   'redis' => array(
     'host' => '/var/run/redis/redis.sock',
     'port' => 0,
      ),

but as soon as I uncomment the memcache local line I get

As soon as I uncomment the memcache.local stanza, I get:

Memcache \OC\Memcache\APCu not available for local cache Is the matching PHP module installed and enabled?

which surprises me, because it is loaded:

root@ida:~# php -m|grep apcu
apcu

And yes, I restart the webserver (several times, to be sure)

And with the lines as they are now, NextCloud does not feel any faster than before and there is no indication is the redis server log that it is receiving any requests. So what is the point of this anyway?

Also I tried

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

but that just gives a blank page.

I find no single entry in the redis server log after the startup message saying that it is listening on socket /var/run/redis/redis.sock
So clearly this is not having an effect so fact and the documentation doesn’t provide any further hints.

I don’t get a blank page if I put
’host’ => ‘localhost’,
‘port’ => 6379,
into the config. So there must be a permissions issue with the socket. But I am still waiting for any perfomance improvement. And it is strange how apcu does not work at all. I have double checked, the PHP module is loaded, yet nextcloud says it isn’t.

I tried to enable redis server as described above, but in the step to check for the files redis-server.pid and
redis.sock iam hanging. I think that there´s any errer with permission, but i can´t fix it by myself.
I already restartet and made the steps before 3 times…
Im new to this cloud-stuff, so my installation is based on Ownyourbits Installation

Any suggestions ? Thanks, Mathias.

For using redis with unix socket, there are new optional variables given in admin manual: https://docs.nextcloud.com/server/12/admin_manual/configuration_server/caching_configuration.html#id3

‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘redis’ => array(
‘host’ => ‘/var/run/redis/redis.sock’,
‘port’ => 0,
‘dbindex’ => 0,
‘password’ => ‘secret’,
‘timeout’ => 1.5,
),

I din’t have a deeper look what it is actually about, just thought it could be mentioned :slight_smile:.

It works on my ubuntu18.04 with php-fpm7.2.
Using nano /etc/systemd/system/redis/service to change group and user to www-data
And change the owner and group of /var/lib/redis to www-data
Then run systemctl restart redis and systemctl daemon-reload to restart redis-server