How to Install and Configure Redis on Ubuntu 23.04

Updated: December 3, 2023 By: Khue Post a comment

Redis is an in-memory data structure store that can serve as a temporary database, cache, or message broker. It supports various data types, such as strings, lists, sets, hashes, and more. Redis is fast, flexible, and reliable. The steps below show you how to install and configure Redis on Ubuntu 23.04 LTS. Without any further ado, let’s begin!

1. Update system packages:

sudo apt update

2. Get Redis installed by executing the following command:

sudo apt install redis-server

3. Open the Redis configuration file:

sudo nano /etc/redis/redis.conf

And Change supervised directive to systems:

supervised systemd

Save and close the file by pressing: Ctrl + X, then Y, and Enter.

4. Restart Redis service:

sudo systemctl restart redis.service

5. Test if Redis is working:

redis-cli ping

You should see this output:

PONG

6. Open the config file to secure Redis with a password:

sudo nano /etc/redis/redis.conf

Uncomment and modify requirepass directive:

requirepass your_password

Save your change and exit the file: Ctrl + X, Y, Enter.

7. Restart Redis service:

sudo systemctl restart redis.service

8. Check if Redis is secured:

redis-cli ping

Output:

NOAUTH Authentication required

Try again but authenticate with your password:

redis-cli -a your_password ping

This time, it works like a charm:

PONG

Done!