Install Redis Server on Linux

Step 1 — Installing

  • sudo apt update
  • sudo apt install redis-server

Step 2 — Testing Redis

Start by checking that the Redis service is running:

  • sudo systemctl status redis

 

Here, you can see that Redis is running and is already enabled, meaning that it is set to start up every time the server boots.

  • sudo systemctl disable redis

To test that Redis is functioning correctly, connect to the server using the command-line client:

  • redis-cli

In the prompt that follows, test connectivity with the ping command:

  • 127.0.0.1:6379>ping
  • Output: PONG
  • 127.0.0.1:6379>set test “It’s working!”
  • Output: OK
  • 127.0.0.1:6379>get test
  • Output: “It’s working!”
  • 127.0.0.1:6379>exit

Step 3 — Binding to localhost

sudo nano /etc/redis/redis.conf

Locate this line and make sure it is uncommented (remove the # if it exists):

bind 127.0.0.1 ::1

Then, restart the service to ensure that systemd reads your changes:

  • sudo systemctl restart redis
Last Updated On June 17, 2021