Install Redis® from Source on Debian 10

Updated on June 22, 2024
Install Redis® from Source on Debian 10 header image

Introduction

Redis® is an in-memory data structure store used as a database, message broker, and cache. It implements a distributed key-value store system. It supports many kinds of data structures. In this tutorial, we will build Redis® from source on Debian 10.

Prerequisites

1. Install Dependencies

Build tools

To build Redis®, we need build tools like compilers and make. Debian bundles these packages in the build-essential metapackage. We also need the pkg-config package. To install these dependencies, run

# apt install pkg-config build-essential -y

Git

Git is a source control tool that will be used to retrieve the source code from the repository. Install it with the following command.

# apt install git -y

2. Install Redis®

First, you must choose which version of Redis® you are going to install. You can select the latest (unstable) version directly from Git, or you can get old versioned stable release.

Create the install directory

First, we will change directories to /opt (and create it in case it does not exist), a place to store software not installed through the package manager.

# mkdir /opt
# cd /opt

Select Version to Install

Unstable

To get the very latest Redis® from git (unstable):

# git clone https://github.com/antirez/redis

Change directories to the folder.

# cd redis

Stable

To get the latest stable, find the link at the Redis® download page. As of this writing, the latest stable Redis is 6.0.5.

# wget http://download.redis.io/releases/redis-6.0.5.tar.gz

Extract the compressed archive (adjusting the version number to the version you downloaded).

# tar xf redis-6.0.5.tar.gz

Change directories to the folder.

# cd redis-6.0.5

Build Redis®

Redis® uses a Makefile build system. Build it with the following command.

# make

Install it:

# make install

3. Using Redis®

We will now demonstrate some of Redis® features. Start a Redis® server in the background (daemonized):

# redis-server --daemonize yes

Now, connect to the server with redis-cli:

# redis-cli

Test Connectivity

The client's connectivity can be tested with the ping command.

127.0.0.1:6379> ping

You should see in response:

PONG

Assign a Value to a Key

Test assigning a value to a key with the following command.

127.0.0.1:6379> set test "redis works"

You should see in response:

OK

Retrieve the value of the key.

127.0.0.1:6379> get test

You should see in response:

"redis works"

Exit redis-cli

Use the exit command to exit the Redis® CLI interface.

127.0.0.1:6379> exit

Conclusion

Congratulations, you have now built from source and tested Redis® on a Debian 10 Vultr instance.