DebianDebian Based

How To Install Redis on Debian 12

Install Redis on Debian 12

In this tutorial, we will show you how to install Redis on Debian 12. Redis isn’t just another database; it’s a powerful data structure server that supports various data types such as strings, hashes, lists, sets, sorted sets, and more. Beyond its versatility, Redis excels in scenarios where low-latency and high-throughput are critical. It serves as a cache, message broker, and even powers real-time analytics.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Redis on a Debian 12 (Bookworm).


  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Redis.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Redis on Debian 12 Bookworm

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update

This command will refresh the repository, allowing you to install the latest versions of software packages.

Step 2. Installing Redis on Debian 12.

  • Method 1: Installing Redis from the Debian Repository

Here are the steps to install Redis from the Debian repository:

sudo apt install redis-server

Once the installation is complete, Redis will start automatically. You can check the status of Redis by running the following command:

sudo systemctl status redis-server

To test if Redis is working properly, you can run the following command:

redis-cli ping

If Redis is working properly, it will return PONG.

  • Method 2: Installing Redis from the Source Code

If you prefer to install Redis from the source code, you can follow these steps. First, install the build dependencies:

sudo apt update
sudo apt install build-essential tcl

Next, download the latest stable version of Redis from the official website:


Extract the downloaded file:

tar xzf redis-7.0.9.tar.gz

Change to the extracted directory:

cd redis-7.0.9

Build Redis:


Install Redis:

sudo make install

Start Redis:


To test if Redis is working properly, you can run the following command:

redis-cli ping

If Redis is working properly, it will return PONG.

Step 3. Configure Redis Server.

To configure the Redis server on Debian Linux using command line options, you can follow these steps:
sudo nano /etc/redis/redis.conf

Find the line that starts with bind and change it to the following:


This will ensure that Redis only listens for connections on the localhost interface.

Find the line that starts with protected-mode and change it to the following:

protected-mode no

This will disable Redis’ protected mode, which is enabled by default and only allows connections from localhost.

Find the line that starts with the port and change it to the desired port number. For example:

port 6379

This will set the Redis server to listen on port 6379.

Save and close the configuration file.

Restart the Redis service to apply the changes:

sudo systemctl restart redis

Verify that Redis is running and listening on the correct port by running the following command:

redis-cli ping

If Redis is working properly, it will return PONG.

Step 4. Managing Redis.

Efficiently manage your Redis instance with these practices:

  • Interacting with Redis CLI:

Use the Redis command-line interface (CLI) to execute various commands:

  • Monitoring Redis Performance:
Redis provides an INFO command that offers crucial performance metrics. Keep an eye on memory usage, clients, and more:
redis-cli INFO

Step 5. Troubleshooting Common Issues.

Even with meticulous planning, issues can arise. Here are strategies to address two common problems:

  1. Addressing Memory Exhaustion: Redis operates in memory, making memory management critical. Set an appropriate value for the maxmemory configuration parameter to avoid running out of memory. Configure eviction policies to remove less frequently used data when memory limits are reached.

  2. Dealing with Data Corruption: While Redis offers persistence mechanisms, data corruption can still occur. Understand how Redis persistence works, and implement a robust backup strategy. Regularly test your backups to ensure data integrity.

Congratulations! You have successfully installed Redis. Thanks for using this tutorial for installing the latest version of Redis on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Redis website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button