This article will take you through how to install Redis on Debian 11. Redis is a distributed, in-memory key-value database, cache, and message broker with optional durability that is used as an in-memory data structure store. Redis supports a wide range of abstract data structures, including strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indices.
How to install Redis on Debian 11
- Update your Debian 11.
sudo apt update
- Next, install Redis using the command below.
sudo apt install redis-server
Sample output
Reading package lists... Done Building dependency tree... Done Reading state information... Done The following package was automatically installed and is no longer required: linux-image-5.10.0-9-amd64 Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: libjemalloc2 liblua5.1-0 liblzf1 lua-cjson redis-tools Suggested packages: ruby-redis The following NEW packages will be installed: libjemalloc2 liblua5.1-0 liblzf1 lua-cjson redis-server redis-tools 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. Need to get 1,224 kB of archives. After this operation, 5,288 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://deb.debian.org/debian bullseye/main amd64 libjemalloc2 amd64 5.2.1-3 [248 kB] Get:2 http://deb.debian.org/debian bullseye/main amd64 liblua5.1-0 amd64 5.1.5-8.1+b3 [109 kB] Get:3 http://deb.debian.org/debian bullseye/main amd64 liblzf1 amd64 3.6-3 [10.2 kB] Get:4 http://deb.debian.org/debian bullseye/main amd64 lua-cjson amd64 2.1.0+dfsg-2.1 [17.5 kB] Get:5 http://deb.debian.org/debian bullseye/main amd64 redis-tools amd64 5:6.0.16-1+deb11u2 [741 kB] Get:6 http://deb.debian.org/debian bullseye/main amd64 redis-server amd64 5:6.0.16-1+deb11u2 [98.2 kB] Fetched 1,224 kB in 2s (504 kB/s) Selecting previously unselected package libjemalloc2:amd64. (Reading database ... 145999 files and directories currently installed.) Preparing to unpack .../0-libjemalloc2_5.2.1-3_amd64.deb ... Unpacking libjemalloc2:amd64 (5.2.1-3) ... Selecting previously unselected package liblua5.1-0:amd64. Preparing to unpack .../1-liblua5.1-0_5.1.5-8.1+b3_amd64.deb ... Unpacking liblua5.1-0:amd64 (5.1.5-8.1+b3) ... Selecting previously unselected package liblzf1:amd64. Preparing to unpack .../2-liblzf1_3.6-3_amd64.deb ... Unpacking liblzf1:amd64 (3.6-3) ... Selecting previously unselected package lua-cjson:amd64. Preparing to unpack .../3-lua-cjson_2.1.0+dfsg-2.1_amd64.deb ... Unpacking lua-cjson:amd64 (2.1.0+dfsg-2.1) ... Selecting previously unselected package redis-tools. Preparing to unpack .../4-redis-tools_5%3a6.0.16-1+deb11u2_amd64.deb ... Unpacking redis-tools (5:6.0.16-1+deb11u2) ... Selecting previously unselected package redis-server. Preparing to unpack .../5-redis-server_5%3a6.0.16-1+deb11u2_amd64.deb ... Unpacking redis-server (5:6.0.16-1+deb11u2) ... Setting up libjemalloc2:amd64 (5.2.1-3) ... Setting up lua-cjson:amd64 (2.1.0+dfsg-2.1) ... Setting up liblzf1:amd64 (3.6-3) ... Setting up liblua5.1-0:amd64 (5.1.5-8.1+b3) ... Setting up redis-tools (5:6.0.16-1+deb11u2) ... Setting up redis-server (5:6.0.16-1+deb11u2) ... Created symlink /etc/systemd/system/redis.service → /lib/systemd/system/ redis-server.service. Created symlink /etc/systemd/system/multi-user.target.wants/redis-server .service → /lib/systemd/system/redis-server.service. Processing triggers for man-db (2.9.4-2) ... Processing triggers for libc-bin (2.31-13+deb11u3) ...
- Enable Redis to start on system boot and start it using the command below.
sudo systemctl enable redis-server --now
- Confirm Redis is running.
systemctl status redis-server
Sample output
● redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-09-07 09:54:33 EAT; 46s ago Docs: http://redis.io/documentation, man:redis-server(1) Main PID: 33721 (redis-server) Status: "Ready to accept connections" Tasks: 5 (limit: 4623) Memory: 7.4M CPU: 148ms CGroup: /system.slice/redis-server.service └─33721 /usr/bin/redis-server 127.0.0.1:6379
- To check the version of Redis that is installed, use the command below.
redis-server -v
- Do a ping test to verify the Redis server is working.
redis-cli
ping
Sample output
127.0.0.1:6379> ping PONG 127.0.0.1:6379> exit
Set Redis password on Debian 11
- Open the Redis configuration file using the command below.
sudo nano /etc/redis/redis.conf
Next, search for requirepass foobared and uncomment it by removing the # symbol then replace foobared with your preferred password.
# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility # layer on top of the new ACL system. The option effect will be just setting # the password for the default user. Clients will still authenticate using # AUTH as usually, or more explicitly with AUTH default # if they follow the new protocol: both will work. # requirepass YourStrongPassword # Command renaming (DEPRECATED). # # ------------------------------------------------------------------------ # WARNING: avoid using this option if possible. Instead use ACLs to remove # commands from the default user, and put them only in some admin user you # create for administrative purposes. # ------------------------------------------------------------------------ #
- Restart Redis to apply changes using the following command.
sudo systemctl restart redis
- Let’s do the ping test again, authentication will be required.
redis-cli
Sample output
127.0.0.1:6379> ping (error) NOAUTH Authentication required. 127.0.0.1:6379> auth YourStrongPassword OK 127.0.0.1:6379> exit
- That concludes our guide on how to install Redis on Debian 11.
Read more on Redis Documentation