How To Install Redis on Debian 11

Install Redis on Debian 11

In this tutorial, we will show you how to install Redis on Debian 11. For those of you who didn’t know, Redis is an open-source (BSD licensed) in-memory database for storing data structure, caching, and as a message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of Redis on a Debian 11 (Bullseye).

Install Redis on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

Step 2. Installing Redis on Debian 11.

By default, Redis 5 series is available on the base Debian 11 repositories. Now run the following command to install it:

sudo apt install redis-server

Once the installation is successful, checks the Redis service status using the following command below:

sudo systemctl status redis-server

Step 3. Configuring Redis.

The main configuration file of Redis Server is found at /etc/redis/redis.conf:

sudo nano /etc/redis/redis.conf

Search for a line that begins with bind 127.0.0.1 ::1 and comment on it:

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT OUT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1 ::1

Next, increase the max memory limit as per available memory on your server:

maxmemory 256mb
maxmemory-policy allkeys-lru

Save the file and close. Then restart the Redis service for changes to take effect:

sudo systemctl restart redis-server

Step 4. Configure Firewall.

Now add a firewall rule that enables traffic from your remote machines on TCP port 6379:

sudo ufw allow proto tcp from <your ip address> to any port 6379

Step 5. Testing Redis.

To access Redis Server, run the command below on the terminal:

redis-cli

Now type “ping” on the Redis command prompt. On successful connection with the Redis server, you will get PONG as a result:

127.0.0.1:6379> ping
PONG

Congratulations! You have successfully installed Redis. Thanks for using this tutorial for installing the latest version of Redis on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Redis website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!