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.
Installation
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.
Configure
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.
Change it to systemd. This will enable redis to interact with your system supervision tree.
Now search for the below line.
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.
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
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
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 95601 (redis-server)
Tasks: 4 (limit: 23692)
Memory: 2.4M
CGroup: /system.slice/redis-server.service
└─95601 /usr/bin/redis-server 127.0.0.1:6379
Jun 25 18:09:51 Dell-XPS-Computer systemd[1]: redis-server.service: Can't open PID file /run/redis/redis-server.pid (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.