Redis is an open-source in-memory key-value data structure store that can be used as a cache server, message broker, etc. We can use a number of data types with redis like strings, lists, maps, sets, sorted sets, HyperLogs, bitmaps, streams, and spatial indexes.

It also provides a number of features like,

  • Replication
  • data persistence
  • LRU eviction
  • High availability using sentinel
  • Publish / Subscribe support for data
  • Keys with limited TTL
  • Automatic Failover
  • LUA scripting, etc

Recommended Read: Install Redis on Ubuntu

Also Read: How to Host Multiple Websites with Nginx in Linux

So let’s start the process to install Redis on CentOS or RHEL.

Install Redis on CentOS

Redis packages are available on EPEL repository, so we are required to install the EPEL repository on our CentOS/ RHEL system first. Install it with the following command,

# yum install epel-release

Once the epel repository has been installed, we can install redis with the following command,

# yum install redis

Start service using the following command,

# systemctl start redis

Another method to install Redis on CentOS

With this method, we can install the latest version of redis or for that matter any version we need. We will installing the latest version at this time, i.e. 6.0.9.. Download the redis package with the following command,

# wget

Next extract the redis package,

# tar -xvf  redis-6.0.9.tar.gz

Now goto the extracted folder,

# cd redis-6.0.9

& then goto folder ‘deps’,

$ cd deps

next compile packages, ,

$ make hiredis lua jemalloc linenoise

$ make geohash-int

Next, we will move back to the main directory i.e. ‘redis-6.0.9’

$ cd ../

execute  ‘make’ & ‘make install’ commands

$ make

$ make installation

Once these commands have been executed, we will install the init scripts, init script will setup a redis service with port number, config file, log file & a data directory. To run run init script,

$ cd utils\

& run the script,

$ ./

We will now be asked with some information regarding redis server, as shown below,

Welcome to the redis service installer

This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]

Selecting default: 6379

Please select the redis config file name [/etc/redis/6379.conf]

Selected default – /etc/redis/6379.conf

Please select the redis log file name [/var/log/redis_6379.log]

Selected default – /var/log/redis_6379.log

Please select the data directory for this instance [/var/lib/redis/6379]

Selected default – /var/lib/redis/6379

Please select the redis executable path [/usr/local/bin/redis-server]

Selected config:

Port : 6379

Config file : /etc/redis/6379.conf

Log file : /var/log/redis_6379.log

Data dir : /var/lib/redis/6379

Executable : /usr/local/bin/redis-server

Cli Executable : /usr/local/bin/redis-cli

Is this ok? Then press ENTER to go on or Ctrl-C to abort.

Copied /tmp/6379.conf => /etc/init.d/redis_6379

Installing service…

Successfully added to chkconfig!

Successfully added to runlevels 345!

Starting Redis server…

Installation successful!

Modify any settings as per your requirements & can also install more than one redis instances by just changing the redis port number.

Now to start the redis service, command is a bit different as service name will be different,

# systemctl start redis_6379

So just change the port number to start only a single redis instance.

Testing Redis installation

We can now check if the redis has been installed by running the following command,

$ redis-cli –version

We can also connect to the installed redis server with the following command,

$ redis-cli

then check the response to ping command for redis,

redis > PING

In response, we should get PONG as output.

Allowing remote connections to Redis installation

By default, we can only connect to redis server from the local server. To allow connections to redis installation from remote machines, we need to make changes to redis configuration file,

$ sudo vi /etc/redis/redis.conf

then look for section that says ‘bind’ & change it


to allow connections from all remote servers or we can also mention single or multiple IP addresses to allow connections from those servers only, like


here, connections will be allowed from two machines with IP addresses & from

Once the changes have been made, we need to restart the redis service to apply changes,

$ sudo systemctl restart redis

This completes our tutorial on how to install Redis on CentOS & RHEL. Please do send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.