How to setup Redis on Linux

How to setup Redis on Linux

Redis, the open-source in-memory data structure store, has become popular among developers for its exceptional performance and versatility.

What makes Redis useful

Redis offers a wide range of features like caching, real-time analytics, queuing, etc. That makes it an ideal choice for different types of applications. Its in-memory architecture allows it to deliver data at lightning-fast speeds. Its support for various data structures like strings, lists, sets, and hashes, makes it a powerful tool for building complex applications. Redis is also easy to use, deploy, and scale, making it a developer's favorite. In this article, we'll explore Redis and how to set it up on a Linux machine.

How to setup Redis on Linux

NOTE: It's not always applicable but you may need to run an update on your machine to proceed.

Step 1 - Installing Redis using the Terminal

In Arch

sudo pacman -S redis

In Ubuntu

sudo apt install redis

In CentOs

sudo yum install redis

In Fedora

sudo dnf -y install redis

Step 2 - Check the Redis Version

Once the installation is complete, you can check if the installation was successful using this command below:

redis-cli --version

Step 3 - Start the Redis Service

sudo systemctl start redis

Step 4 - Enable the Redis Service

To automatically start Redis on boot run the command below

sudo systemctl enable redis

Step 4 - Verify your installation

sudo systemctl status redis

You should now see something similar to the image below. In the output, locate the Active: active (running) line.

NOTE: If what you saw is Active: inactive, then it means that you must have missed Step 3.

You can also verify your installation using this Ping command

redis-cli ping

The expected return should be PONG.

Your Redis Config

Wondering how you can connect to your Redis server? Well, you can just copy the address below and set it as your Redis address and you are good to go.

NOTE: Redis runs on port 6379

127.0.0.1:6379

I hope you found this helpful. Happy coding ;)