How To Install Redis on Debian 10

Post Reply
User avatar
webxtek
Posts: 27
Joined: Wed Nov 18, 2020 7:43 pm
How To Install Redis on Debian 10

Post by webxtek »

Hi,

Here's how to install Redis on Debian 10:

You must have shell access with sudo privileged account access to Debian 10 system. First of all, log in to your system and upgrade the current packages.


1st run:

Code: Select all

sudo apt update 

Code: Select all

sudo apt upgrade
2nd run

Code: Select all

sudo apt install redis-server
After installation, enable Redis service to start on system boot.

Code: Select all

sudo systemctl enable redis-server
Now navigate to your /etc/redis/redis.conf file and add this 2 lines on the end of the file:

Code: Select all

maxmemory 256mb
maxmemory-policy allkeys-lru
The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:

Code: Select all

sudo systemctl restart redis-server
Install Redis PHP Extension (This is an optional step. If you need to connect Redis from PHP application, You need to install Redis PHP extension on your Debian system. To install Redis PHP extension, simply type:)

Code: Select all

sudo apt install php-redis
The installer will automatically enable redis extension for all the pre installed PHP versions. If you installer new PHP version after this, you can use below command to enable redis module. For example to enable extension for PHP 7.4, type:

Code: Select all

sudo phpenmod -v 7.4 -s ALL redis
Now Connect to Redis Server


Use redis-cli tool to verify the connection between the Redis server

Code: Select all

redis-cli

127.0.0.1:6379> ping
PONG
Few more examples of redis-cli command line tool:

Code: Select all

$ redis-cli info
$ redis-cli info stats
$ redis-cli info server
This tutorial helps you with the installation of Redis server on Debian 10 system.
Last edited by webxtek on Wed Dec 30, 2020 4:21 am, edited 1 time in total.

User avatar
dpeca
Site Admin
Posts: 551
Joined: Fri Jun 19, 2020 9:59 am
Your location: Serbia, Niš and Belgrade
First name and last name: Predrag Damnjanović
Re: How To Install Redis on Debian 10

Post by dpeca »

Thanks a lot <3


Post Reply