HugeServer Knowledgebase

How to install Redis 4 on Debian 9 (Stretch)


Redis is a flexible open-source, key-value data store, used as a database, cache and message broker. Redis allows the user to store vast amounts of data without the limits of a relational database.
In order to achieve its outstanding performance, Redis works with an in-memory dataset. Depending on your use-case, you can persist it either by dumping the dataset to disk every once in a while or by appending each command to a log. Persistence can be optionally disabled if you just need a feature-rich, networked, in-memory cache.

We are assuming that you have root permission, otherwise, you may start commands with “sudo”.

Install dependencies

Redis 4 is not provided by any repository yet, so we have to compile it from source. In order to compile Redis 4 you have installed the “build essential” package:

apt-get install build-essential tcl

Download Redis 4 source

We can download the Redis source from its official website with the following command:


After the download is finished you have to extract it with the following command:

tar xvzf redis-stable.tar.gz

Compile Redis

In the previous versions you had to compile “hiredis”, “jemalloc” and “lua” first, But in version 4 you can go ahead and compile Redis right away and the process will take care of the dependencies.

Switch to the Redis source file directory:

cd redis-stable

Execute the following command will completely install Redis:

make && make install

After the installation process is finished, execute the following command to make sure that everything is OK!

make test

Create the Redis service

Redis 4 has a script that creates the necessary files and directories automatically.
Switch to the following directory:

cd utils/

Run the “” script with the following command:


Hit enter for all of the prompts to get the default configuration.
Now you can use the following commands to start and make your Redis service run at startup:

systemctl start redis_6379

systemctl enable redis_6379

Test if Redis is working properly

You can execute the following command to see if Redis is listening on the preferred port:

netstat -ln | grep 6379

You should see the following line in your output:

tcp        0      0*               LISTEN

Also, you can test the Redis using the “redis-cli”:


$ set test HugeServer

$ get test

Now you should see:


For more information and news, check out Redis official website!

Was this tutorial helpful?

Thank you for your vote.Thank you for your vote.

Similar Posts

4 thoughts on “How to install Redis 4 on Debian 9 (Stretch)”

Leave a Reply

Your email address will not be published. Required fields are marked *