How to Install Redis on Debian 10

Install Redis on Debian 10

In this article, we will have explained the necessary steps to install and configure Redis on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Redis (Remote Dictionary Server) is an open-source, in-memory database that is used as a cache and message broker. Some of Redis features are built-in transactions, replication, and support for a variety of data structures like strings, hashes, lists, sets and so on. Redis Sentinel makes Redis highly available and it supports automatic partitioning with Redis Cluster.

Install Redis on Debian

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Install Redis.

Redis package is available in default repository in Debian 10. So to install Redis run below command:

sudo apt install redis-server

After installing Redis it will start automatically so to confirm installation and check Redis status run below command:

sudo systemctl status redis-server

Step 3. Configure Redis.

First, run below command and open Redis configuration file:

sudo nano /etc/redis/redis.conf
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 0.0.0.0 ::1

To take changes effect, restart Redis server using command:

sudo systemctl restart redis-server

Use the following command to verify that the Redis server is listening on your private interface on port 6379:

ss -an | grep 6379

You should see something like below:

tcp    LISTEN     0      128    192.168.121.233:6379            *:*
tcp    LISTEN     0      128    127.0.0.1:6379                  *:*

To verify that everything is setup properly, you can try to ping the Redis server from your remote machine using the redis-cli utility which provides a command-line interface to a Redis server:

redis-cli -h <REDIS_IP_ADDRESS> ping

You should see exact below output:

PONG

Congratulation, you have learned how to install and configure Redis on Debian 10 Buster. If you have any question, please leave a comment below.