You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

In this tutorial, I’ll walk you through the steps to install Redis Server on Ubuntu 18.04 / Debian 9. Redis is an Open Source in-memory data structure store. Redis can be used as a database server, as a message broker or for caching data in memory for faster retrieval.

Redis supported data structures are:

  • Hashes
  • sets with range queries
  • Strings
  • sorted lists
  • Hyperloglogs
  • Bitmaps
  • Geospatial indexes e.t.c

For CentOS 8 / CentOS 7 / Fedora use:

How to Install Latest Redis on CentOS 7

How to Install Redis on Fedora 29 / Fedora 28

Install and Configure Redis Server on RHEL 8 / CentOS 8

How to Install Redis on Ubuntu 18.04 / Debian 9

In this section, we will look at how to install the latest release of Redis on Ubuntu 18.04 / Debian 9. You can check the version of Redis Server available on your Ubuntu 18.04 / Debian 9 using the following command.

$ sudo apt policy redis-server
  Installed: (none)
  Candidate: 5:4.0.9-1ubuntu0.1
  Version table:
     5:4.0.9-1ubuntu0.1 500
        500 bionic-updates/universe amd64 Packages
        500 bionic-security/universe amd64 Packages
     5:4.0.9-1 500
        500 bionic/universe amd64 Packages

Step 1: Update your server Package list

Ensure your system is updated before installing Redis

sudo apt update
sudo apt upgrade
sudo reboot

Step 2: Install Redis on Ubuntu 18.04 / Debian 9

Redis Server package is available on the  Ubuntu/Debian upstream repository. After updating your system, install Redis by running the following commands in your terminal.

sudo apt -y install redis-server

If you would like to have a more recent version of Redis Server, you may opt to use PPA repository maintained by Chris Lea.

sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt -y install redis-server

If you don’t have add-apt-repository command on your system, check our previous guide:

How to Install add-apt-repository on Debian 9 / Ubuntu 18.04/16.04

Confirm Redis Server version:

$ redis-server -v
Redis server v=5.0.3 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=45d60903d31a0894

Step 3: Start Redis Service on Ubuntu 18.04 / Debian 9

By default, Redis service should be started after installation. But you can start and enable the service to start on boot manually using the command:

sudo systemctl enable --now redis-server

Step 4: Enable network Listen for Redis Service

For network clients to connect to your Redis server, it needs the service to listen on a network IP Address.

Open the file /etc/redis/redis.conf with your favorite text editor

sudo vim /etc/redis/redis.conf

Then change line  bind to below:


Restart redis service after making the change:

sudo systemctl restart redis-server

Configure Redis Authentication – (Optional but recommended)

Configure Redis Authentication for clients to require AUTH <PASSWORD> before processing any other commands.

requirepass  <AuthPassword>


requirepass oobaiY8BA

Set Persistent Store for Recovery

Set persistence mode by changing the appendonlyvalue to yes

appendonly yes
appendfilename "appendonly.aof"

Restart redis service after making the changes

sudo systemctl restart redis-server

Check redis service status:

$ systemctl status redis-server
* redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-12-23 03:42:41 PST; 1s ago
  Process: 10444 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 10447 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 10469 (redis-server)
    Tasks: 4 (limit: 2319)
   CGroup: /system.slice/redis-server.service
           `-10469 /usr/bin/redis-server

Dec 23 03:42:40 ubuntu-01 systemd[1]: Starting Advanced key-value store...
Dec 23 03:42:41 ubuntu-01 systemd[1]: Started Advanced key-value store.

You can view the port and IP used by Redis service using the sscommand:

$ ss -tunelp | grep 6379
tcp LISTEN 0 128* uid:112 ino:52652 sk:40 <->

If you have an active firewall service, allow port 6379

sudo ufw allow 6379/tcp

Step 5: Test connection to Redis Server

Confirm that you can connect to redis locally:

$ redis-cli>

Test authenticate:> AUTH <AuthPassword>

You should receive OK in the output. If you input a wrong password, Authentication should fail:> AUTH WrongPassword
(error) ERR invalid password

Check redis information.>  INFO

This will output a long list of data. You can limit the output by passing Section as an argument. E.g.> INFO Server
# Server
os:Linux 4.15.0-38-generic x86_64

Step 6: Perform Redis Benchmarking

Run the benchmark with 15 parallel connections, for a total of 10k requests, against local redis to test its performance.

$ redis-benchmark -h -p 6379 -n 10000 -c 15

# Sample output
====== LRANGE_500 (first 450 elements) ======
  10000 requests completed in 0.62 seconds
  15 parallel clients
  3 bytes payload
  keep alive: 1

99.66% <= 1 milliseconds
100.00% <= 1 milliseconds
16129.03 requests per second

====== LRANGE_600 (first 600 elements) ======
  10000 requests completed in 0.81 seconds
  15 parallel clients
  3 bytes payload
  keep alive: 1

99.66% <= 1 milliseconds
99.93% <= 2 milliseconds
99.97% <= 3 milliseconds
100.00% <= 3 milliseconds
12345.68 requests per second

====== MSET (10 keys) ======
  10000 requests completed in 0.09 seconds
  15 parallel clients
  3 bytes payload
  keep alive: 1

100.00% <= 0 milliseconds
111111.11 requests per second

For more options and examples, use:

$ redis-benchmark --help

You have successfully installed Redis on  Ubuntu 18.04 / Debian 9 Server or Workstation.

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF