Install Redis on Ubuntu
Installation

Install Redis on Ubuntu

Sagar Sharma
Sagar Sharma

Table of Contents

Redis is a free and open-source, in-memory data structure store.

In simple terms, Redis stores the data in the RAM instead of the disk which can be very useful in cases of real-time analytics, high-speed transactions, and session management.

And Redis is available in the default repository of Ubuntu (old version) and can be installed with the following command:

sudo apt install redis-server

But as I mentioned, it gets you the old version and while writing, it gave me redis version 6.0.16.

But what if you want the most recent version? Follow the given guide.

How to install the latest version of Redis in Ubuntu

To install the latest version of Redis, you'd have to add the redis repository in Ubuntu.

But before that, if you are running an extremely minimal distro like docker, you'd have to install lsb-release first:

sudo apt install lsb-release

First, download and save the GPG key to your system:

curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

Next, add the redis repository to the list of sources:

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

And finally, update the repository and install the redis:

sudo apt update && sudo apt install redis

Once done, you can check the installed version of redis using the following command:

redis-server --version
check the installed version of redis

And as you can see, it gave me redis-server version 7.0.11 which is one iteration ahead of what you get using the default repository.

Now, start the redis-server service:

sudo systemctl start redis

And enable the service to start itself from the next boot:

sudo systemctl enable redis

To test the redis, first, start the redis-cli instance:

redis-cli

And here, execute PING in all capitals:

PING

And you will receive PONG in output:

testing redis install in ubuntu

To quit the instance, use exit!

Want to secure your web server with NGINX?

If you're running a self-hosted server, you may want to install OpenSSL certificates to secure your server.

Also,  it is entirely free!

We have a detailed guide covering the installation of NGINX, setting up the domain to installing SSL certificates:

Using Certbot With Nginx Web Server
Certbot makes the SSL certificate deployment and renewal such an effortless process. Learn how to use certbot with Ngnix.

I hope you will find this guide helpful.

And if you have any queries or suggestions, feel free to ask in the comments.



Sagar Sharma

Sagar Sharma

A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.