How to install and configure Redis server on Ubuntu 20.04

Redis is open source, fast in-memory data structure store. used for database, cache or message-broker. Redis is widely used for chat messaging application for its speed and flexibility.

In this article we will install and configure Redis server in Ubuntu 20.04 version.


First update your package repository list using apt update command.

sudo apt update

Then install Redis server with below command.

sudo apt install redis-server

Now you have installed Redis server in your system. Now we will need to configure and secure Redis server.


Open the redis config file in nano editor using below command

sudo nano /etc/redis/redis.conf

Find the below line in the General section.

supervised no

Change it to systemd. This will enable redis to interact with your system supervision tree.

supervised systemd

Now search for the below line.

# bind ::1

If there is no bind directive is defined, Redis will listen from connections from all the network interfaces available on the server. So we need to remove comment. This will bind Redis server to listen from localhost only.

bind ::1

Now save and exit the file. You will also need to restart the Redis server.

sudo systemctl restart redis.service

If you want to check the Redis status, you can check with below command.

sudo systemctl status redis
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-06-25 18:09:51 EDT; 9min ago
   Main PID: 95601 (redis-server)
      Tasks: 4 (limit: 23692)
     Memory: 2.4M
     CGroup: /system.slice/redis-server.service
             └─95601 /usr/bin/redis-server
Jun 25 18:09:51 Dell-XPS-Computer  systemd[1]: Starting Advanced key-value store...
Jun 25 18:09:51 Dell-XPS-Computer  systemd[1]: redis-server.service: Can't open PID file /run/redis/ (yet?) after start: Operation not per>
Jun 25 18:09:51 Dell-XPS-Computer  systemd[1]: Started Advanced key-value store.

If your web application is built in PHP language, then you need to install php-redis extension to interact with Redis.

sudo apt install php-redis

For further details, visit Redis documentation site.