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
- A fully-updated Debian 10 server
- Log in to the server as root.
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 -yGit
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 -y2. 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 /optSelect Version to Install
Unstable
To get the very latest Redis from git (unstable):
# git clone https://github.com/antirez/redisChange directories to the folder.
# cd redisStable
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.gzExtract the compressed archive (adjusting the version number to the version you downloaded).
# tar xf redis-6.0.5.tar.gzChange directories to the folder.
# cd redis-6.0.5Build Redis
Redis uses a Makefile build system. Build it with the following command.
# makeInstall it:
# make install3. Using Redis
We will now demonstrate some of Redis's features. Start a Redis server in the background (daemonized):
# redis-server --daemonize yesNow, connect to the server with redis-cli:
# redis-cliTest Connectivity
The client's connectivity can be tested with the ping command.
127.0.0.1:6379> pingYou should see in response:
PONGAssign 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:
OKRetrieve the value of the key.
127.0.0.1:6379> get testYou should see in response:
"redis works"Exit redis-cli
Use the exit command to exit the Redis CLI interface.
127.0.0.1:6379> exitConclusion
Congratulations, you have now built from source and tested Redis on a Debian 10 Rcs instance.
