DEV Community

Cover image for How to setup Redis on linux machine
Mathias Jiya
Mathias Jiya

Posted on • Updated on

How to setup Redis on linux machine

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

For Arch

sudo pacman -S redis
Enter fullscreen mode Exit fullscreen mode

For Ubuntu

sudo apt install redis
Enter fullscreen mode Exit fullscreen mode

For CentOS

sudo yum install redis
Enter fullscreen mode Exit fullscreen mode

For Fedora

sudo dnf -y install redis
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Step 3 - Start the Redis Service

sudo systemctl start redis
Enter fullscreen mode Exit fullscreen mode

Step 4 - Enable the Redis Service

To automatically start Redis on boot run the command below

sudo systemctl enable redis
Enter fullscreen mode Exit fullscreen mode

Step 4 - Verify your installation

sudo systemctl status redis
Enter fullscreen mode Exit fullscreen mode

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.

Redis terminal status image

You can also verify your installation using this Ping command.

redis-cli ping
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

I hope you found this helpful. Happy coding ;)

Top comments (0)