What is Redis?

Redis is a popular system that would increase the speed and performance. It is an open-source, in-memory database used as a cache and message broker. It is also known as a data structure server. This tutorial demonstrates how to install, configure, and secure Redis.

How to install Redis on Ubuntu 22.04

Step 1 — Update system packages

Update your local apt package cache if you haven’t done so recently, using command:

sudo apt update

 Step 2 — Install Redis

install Redis by using command:

sudo apt install redis-server

Step 3 — Check Redis version

verify the version of installed Redis by executing the “redis-server” command with the “-v” option:

redis-server -v

Step 3 — Start Redis Service

Once the installation is complete, we recommend checking if the Redis instance is running. In order to test connectivity, you can use the following command:

sudo systemctl status redis

If Redis hasn’t been started and the status is inactive, you can enable Redis client by entering the following command:

sudo systemctl restart redis-server

How to configure Redis on Ubuntu 22.04

Step 1 — Edit Redis Configuration File

The default Redis configuration file is located in /etc/redis/redis.conf. The default configuration is when the Redis server listens for all available connections. Open it with your preferred editor. In our case, we are using the vi editor.

sudo vi /etc/redis/redis.conf

Locate the line bind ::1.

Change the IP address by entering the values of the connections you want the Redis server to listen for. Here’s an example:


Then, locate the requirepass directive under the SECURITY section and uncomment it (by removing #). Once you have uncommented the line, replace with the password of your choice.

Step 2 — Restart Redis service

Once you are done making changes, save and close the file. Then restart the Redis service to apply the changes:

sudo systemctl restart redis-server