How to install REDIS in LInux

Redis is an open source database, precisely, it’s an in-memory data structure store that can be used as a database, cache & message broker. It does not possess the limits offered by the relational database & can be used to store a vast amount of data, with support for a number of data structures like strings, hashes, lists, sets, Sorted sets, bitmaps, hyperlogs etc.

Redis also provides a number of features like built-in replication (master-slave replication), Lua scripting, LRU eviction, transactions and different levels of on-disk persistence & also provides high availability.

Typical use cases are session caching, full page cache, message queue applications, leaderboards and counting among others.

Recommended Read : Installing MEMCACHED in Ubuntu & RHEL/CentOS

Also Read : Install Varnish Cache for Apache Web Server to Speed up Website


Before we can proceed with the installation of Redis on our Centos/RHEL servers, we need to make sure that following packages must be installed on our systems,

1- CentOS/RHEL 7

We need to install the following packages,

$ yum install wget gcc make

2- CentOS/RHEL6

Install the following packages,

$ yum install tcl wget gcc make

Step 1- Downloading Redis


At the time of writing this tutorial, redis 5.0.4 is the latest version. So to download the redis 5.0.4, open your terminal & execute the following command,

$ wget

Next, we will extract the downloaded tar package,

$ tar -xvf redis-5.0.4.tar.gz

Step 2- Compiling & installing redis


Now that we have an extracted, we will compile & install redis. Firstly, open the extracted folder,

$ cd redis-5.0.4

& then goto folder ‘deps’,

$ cd deps

Now, we will compile the packages by executing following commands,

$ make hiredis lua jemalloc linenoise

$ make geohash-int

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

$ cd ../

& will run ‘make’ & ‘make install’ commands

$ make

$ make installation

Once these commands have been executed, we will move onto to installing init script.

Step 3- Installing init scripting

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!

For this installation we have used all the default settings, but we can modify any settings as per our need.

Note:- We can also set up a number of redis instances by running this script again & changing the port number for the new redis instance.


Step 4- Starting the redis service

To start the redis service, the command is

$ service redis_6379 start, OR ,

$ systemctl start redis_6379


If you are using more than one redis instance or have changed the port number for redis instance, then you can replace 6379 with the port number you have chosen to stop/start the redis service.


Step 5- Checking if the redis service is working

To login to redis server & check if redis is working fine, open terminal & run the command,

$ redis-cli

Once connected, you will get prompt like>

We can now issue ‘Ping’ command & if the redis service is up, we will get ‘PONG ‘ as response,> ping



Step 6 (OPTIONAL) Accessing redis from remote system


By default, redis is accessible from localhost but if you wish to access redis server from a remote location then we need to make some changes in the configuration file. Open the configuration file for the instance, i.e. /etc/6379.conf,

$ vi /etc/redis/6379.conf

& look for ‘bind’. We can either replace with or add IP address of our server to it. It should look like




Now exit the file after saving the changes & restart the service for changes to take effect.

$ service redis_6379 restart

Remember if using multiple or different port numbers, changes are to made to all the configuration files for respective port numbers.

Now to check if we can login to redis from a remote system, login to remote system first & enter the following command from terminal,

$ redis-cli -h -p 6379

where, is the IP address of the redis server with 6379 as the redis instance port number.

This completes our tutorial on redis installation. For any queries or questions , you are most welcome to contact us 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 | Google Plus

Donate us some of you hard earned money:

Linux TechLab is thankful for your continued support.


Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

5 Responses

  1. Jay says:

    Thank you, it worked.

  2. YM says:

    ]# make installation
    cd src && make installation
    make[1]: Entering directory `/tmp/redis/redis-4.0.9/src’
    make[1]: *** No rule to make target `installation’. Stop.
    make[1]: Leaving directory `/tmp/redis/redis-4.0.9/src’
    make: *** [installation] Error 2

  3. srinath says:

    Should we install redis with root ? or can we use an application user account to install or configure just redis part.

    • Shusain says:

      What you can do is that you install it using root & than make the service run with a non root user. To do that,

      add a user
      change ownership of redis-server & redis-cli to that user,
      & than create a script like,
      $ vim /usr/lib/systemd/system/redis.service

      Description=Redis In-Memory Data Store
      ExecStart=”the absolute path of redis-server” “ths absolute path of redis.conf”
      ExecStop=”the absolute path of redis-cli” shutdown

Leave a Reply

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