How to install Redis on Ubuntu 20.04. Redis is a key-value store known for performance and flexibility.
In this guide you are going to learn how to install and configure Redis on Ubuntu 20.04.
This setup is tested on Google Cloud with an Ubuntu OS, so this setup will work on any cloud services like AWS, Azure or any VPS or dedicated servers.
- SSH access to the server.
Step 1: Install Redis
Start by updating the packages to latest version.
sudo apt update
Install Redis using the following command.
sudo apt install redis-server
Once the installation is completed you can check the version of Redis using the following command.
Output Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=636cde3b5c7a3923
Step 2: Configure Redis as a Service
To get more control over Redis operations it is necessary to configure an init system to manage it as a service.
By default the
supervised directive in Redis configuration is set to
no which is the one that declares the init system.
Change the value to
systemd to use the Ubunut’s init system.
Open the configuration file located in
sudo nano /etc/redis/redis.conf
Make changes to the supervised value to systemd so that it looks like below.
. . . supervised systemd . . .
CRTL + X followed by
Enter to save and exit the file.
Restart Redis for the changes to take effect.
sudo systemctl restart redis.service
Step 3: Check Redis Status
Check Redis status using the
systemctl command after the service is restarted.
sudo systemctl status redis
You will receive an output similar to the one below which indicates Redis is working fine.
Output ● redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2020-09-02 05:53:14 UTC; 5s ago Docs: http://redis.io/documentation, man:redis-server(1) Process: 17433 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS) Main PID: 17444 (redis-server) Tasks: 4 (limit: 682) Memory: 1.8M CGroup: /system.slice/redis-server.service └─17444 /usr/bin/redis-server 127.0.0.1:6379
Now Redis will get started automatically every time the system boots up.
If you wish to start up Redis manually for some use cases you can disable the service using the following command.
sudo systemctl disable redis
That’s it. Now you have your Redis server running on your Ubuntu 20 .04.
Now you have learned how to install and configure Redis server on Ubuntu 20.04.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.