Home // How to install Redis for Nextcloud
1 3 mins read
| Published on: December 28, 2022 | Last updated on: September 12, 2023

Redis, which stands for Remote Dictionary Server, is a fast, key-value data store that works in memory and is free to use. Salvatore Sanfilippo, who made Redis in the first place, started the project because he wanted to make his Italian startup more scalable. From there, he made Redis, which is now used as a database, cache, message broker, and queue.

Redis supposedly has response times of less than one millisecond, which lets it handle millions of requests per second for real-time applications in fields like gaming, ad-tech, financial services, healthcare, and the Internet of Things (IoT). Today, Redis is one of the most popular open-source engines. For the past five years in a row, Stack Overflow has named it the “Most Loved” database. Redis is often used in caching, session management, gaming, leaderboards, real-time analytics, geospatial, ride-hailing, chat/messaging, media streaming, and pub/sub apps because it works quickly.

Most major Linux distributions provide packages for Redis, making it a versatile tool. You can also find Redis in the context of Nextcloud for improved performance and caching.


For those running a minimal distribution, such as a Docker container or an LXC container, there may be a need to install lsb-release first. This package provides essential information about the Linux distribution in use.

  • Machine Used: LXC Container running Ubuntu 20.04

Here’s how you can install lsb-release:

sudo apt install lsb-release

Note: Installing this package ensures compatibility with various scripts and applications that rely on specific distribution information. It’s particularly useful in containerized environments where such information might not be readily available.

Step 1 – Install Redis for Nextcloud


Install it from the Ubuntu repository using the APT package manager. At the time of this writing, 5.0.7 may be found in the default repositories.

To get started, use sudo apt update to refresh the apt package cache on your machine.

Next, type sudo apt install redis-server to set up Redis.

Remote Access

If you’d like to connect applications that are not on the machine, we can do it this way.

sudo nano /etc/redis/redis.conf

Change bind to bind . Save and exit and then run:

sudo service redis-server restart


You’ll need to install the redis php module on the nextcloud server as well:

sudo apt install php-redis

Step 2 — Testing Redis-Server

Prior to making any more changes to Redis’ setup, it’s a good idea to verify that it’s working as intended, as you would with any freshly installed program. We will go through two techniques to confirm that Redis is operating appropriately in this stage.

Start by confirming that the Redis service is operating

sudo systemctl status redis

If it is running without any errors, this command will produce output similar to the following:

Connect to the server using redis-cli, the command-line client for Redis, to verify that it is operating properly:


Should be more than enough for testing its connectivity. You also confirmed that the machine

Step 3 – Connect it to Nextcloud

Local Redis

At this point we know Redis is functional and ready to be implement into our Nextcloud instance. Head to your Nextcloud config folder, edit the config.php and add these lines:

'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'localhost',
'port' => 6379,
'timeout' => 0.0,

Remote Redis server

If you want to use a remote redis server you need to set the ip or FQDN of the Redis machine in the ‘host’ parameter:

'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'CHANGEME',
'port' => 6379,
'timeout' => 0.0,


That’s it, your Nextcloud instance should automatically start using redis for memory caching and help prevent deadlocks.

Find out more about redis

Optimizing Redis for Nextcloud

After successfully installing and connecting Redis to your Nextcloud instance, you may want to take advantage of several optimization techniques to further enhance performance. Below are some tips and tuning suggestions that you can apply to make the best use of Redis with Nextcloud.

1. Tuning Redis Configuration

Redis’s performance can be tailored to your needs by adjusting its configuration file (/etc/redis/redis.conf).

  • Max Memory: Depending on your system’s available memory, you might want to set a limit on how much memory Redis can use. This ensures that Redis won’t consume all available system memory.
  maxmemory 256mb
  maxmemory-policy allkeys-lru
  • Persistence Options: Depending on your needs, you can enable or disable persistence to improve performance. If data persistence is not critical for your application, disabling it can free up I/O resources.
  appendonly no
  • TCP Keepalive: Set a proper value for TCP keepalive to ensure a more reliable connection.
  tcp-keepalive 300

2. Monitoring Redis Performance

Redis offers several tools to monitor its performance and behavior. Using tools like redis-cli and redis-benchmark, you can track real-time statistics and run tests to see how well your Redis instance is performing.

  • Monitoring Commands: Use redis-cli monitor to observe all the commands processed by the server in real-time.
  • Benchmarking: Run redis-benchmark to test how many requests per second your Redis server can handle.

3. Securing Redis

If your Redis instance is exposed to the network (e.g., binding to, make sure to implement security measures to prevent unauthorized access:

  • Set a Strong Password: You can configure a password in the Redis configuration file.
  requirepass your-strong-password
  • Use Firewall Rules: Allow only trusted IPs to connect to your Redis port (usually 6379).


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

Copyright @2022-2024 All Right Reserved – PCPlanet

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. You understand and give your consent that your IP address and browser information might be processed by the security plugins installed on this site. By clicking “Accept”, you consent to the use of ALL the cookies.
Accept Read More

Privacy & Cookies Policy