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 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.
If you’re running a very minimal distribution (such as a Docker container) you may need to install lsb-release first:
sudo apt install lsb-release
- Machine Used – LXC Container running Ubuntu 20.04
Step 1 – Install Redis
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.
sudo apt install redis-server to set up Redis.
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
bind 127.0.0.1 to
bind 0.0.0.0 . 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
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.