How To Install and Secure Redis on Ubuntu

In order to get the latest version of Redis, we will use apt to install it from the official Ubuntu repositories.

Update your local apt package cache and install Redis by typing:

$ sudo apt update
$ sudo apt install redis-server

This will download and install Redis and its dependencies.

If on A regular Ubuntu distribution, change the configuration for the server to run as a service.

Open this file with your preferred text editor:

$ sudo nano /etc/redis/redis.conf

Change the following:

supervised no

Change as below.

supervised systemd

Restart

# sudo systemctl restart redis.service

On WSL ubuntu:

sudo /etc/init.d/redis-server restart

Start by checking that the Redis service is running:

$ sudo systemctl status redis

on WSL ubuntu

$ sudo /etc/init.d/redis-server status
* redis-server is running

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
PONG

Leave a Comment