Redis is an open-source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, HyperLogLogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

In this guide, we will explain how to install and configure Redis on an Ubuntu 16.04 server.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo apt-get update && sudo apt-get upgrade

It is also you required that you install the software-properties-common package if it is not presently installed:

sudo apt-get install software-properties-common

Step 1: Add Redis Repository
Next, we need to add a third-party PPA which contains the Redis package. At the prompt, Press [ENTER] to continue.

sudo add-apt-repository ppa:chris-lea/redis-server

Installing and Configuring Redis on Ubuntu

Step 2: Update and Install
After adding the PPA, we need to update our system packages before proceeding to install the redis-server using the command below :

sudo apt-get update
sudo apt-get install redis-server

Installing and Configuring Redis on Ubuntu

Step 3: Verify the Installation
The next step is to verify that our installation was done successfully with the command below:

  • Your prompt will change to>.
  • Run the command ping, which should return a PONG as shown below

Installing and Configuring Redis on Ubuntu

  • Exit out into the shell again when you are finished:


You can also check that the Redis service is running using the command below:

sudo systemctl status redis

Configuring Redis

Redis provides two options for disk persistence:

  • Append-only logs of all the write operations performed by the server (AOF).
  • Point-in-time snapshots of the dataset, made at specified intervals (RDB)

You can read more in the official Redis documentation.

For the greatest level of data safety, it is advised that you consider running both persistence methods.

The Point-in-time snapshot persistence is enabled by default, hence we are going to set up only the AOF persistence. Type the command below to edit the redis.conf file

sudo nano /etc/redis/redis.conf
  • Locate appendonly and change the default value from no to yes as shown below:

Note: When using nano editor, you can use Ctrl + W to search for keywords.

  • Ensure that appendfsync is set to everysec as shown below:

Next, restart Redis with the command below:

sudo service redis-server restart

Configuring a Redis Password
You can require clients to issue AUTH before processing any other commands. This might be useful in environments in which you do not trust
others with access to the host running Redis-server and for security purposes in general.

Note: This should stay commented out for backward compatibility and because most people do not need auth since they run their own servers

To configure a Redis password, we need to open the redis.conf file using the command below:

sudo nano /etc/redis/redis.conf

Navigate to the SECURITY section and look for a commented directive that reads:

# requirepass foobared

Uncomment it by removing the #, and change foobared to a secure password.

After setting the password, save and close the file, then restart Redis:

 sudo systemctl restart redis

To check that the password works, access the Redis command line:


The following shows a sequence of commands used to test whether the Redis password works. The first command tries to set a key to a value before authentication:

set key1 30

An error would be returned because you didn’t authenticate.

The next command authenticates with the password specified in the Redis configuration file:

auth your_newly_configured_password

Upon entering the new password correctly, you can try the same process again which would now be successful as shown below: