How to install Redis on Ubuntu and CentOS (Linux)

Er Ravindra Pawadia
3 min readDec 18, 2020

Redis is most popular open-source key-value data store in-memory database that can be used as a cache server, message broker, etc. In this guide, we will learn how to install Redis on Ubuntu and CentOS servers. This guide describes how to install Redis on Ubuntu and CentOS (Linux).

Redis also provides a number of features given below,

Install Redis on Ubuntu

By default Redis packages is available in Ubuntu repositories, So just perform a repos update before that,

$ sudo apt update

Next install redis on ubuntu with the below command,

$ sudo apt install redis

Now start the redis service using below command.

$ sudo systemctl start redis

Install Redis on CentOS

Redis packages is available on EPEL repository, so you can install the EPEL repository on our CentOS/ RHEL machine. Install it using below command,

# yum install epel-release

Once the epel repository is installed in your system, you can install redis with the below command,

# yum install redis

Start service using the below command,

# systemctl start redis

Install Redis Using Source on CentOS

Using this method, you can install the latest version of redis. You will installing the latest version at this time, i.e. 6.0.9.. Download the redis package using below command,

# wget https://download.redis.io/releases/redis-6.0.9.tar.gz

Next extract the redis package with the following command,

# tar -xvf redis-6.0.9.tar.gz

Now go to the extracted folder,

next compile packages,

# make hiredis lua jemalloc linenoise 
# make geohash-int

Next, move back to the main directory i.e. ‘redis-6.0.9’. execute below commands.

Once you will execute commands, next you will install the init scripts, init script will setup a redis service with port number, config file, log file & a data directory.

# cd utils\ & run the install_server.sh script, 
# ./install_server.sh

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

Modify settings as per your requirements & you can also install more than one redis instances by just changing the default redis port. Now start the redis service using below command which is different that conventional command,

# systemctl start redis_6379

Testing Redis installation

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

$ redis-cli --version

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

Next check the response to ping command for redis,

In response, you should get PONG as output.

Allowing remote connections to Redis installation

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

$ sudo vi /etc/redis/redis.conf

Then search for section that says ‘bind 127.0.0.1’ & change it

Connections can be allowed from all remote servers or you can also mention single or multiple IP addresses to allow connections from those servers only such as,

bind 10.10.10.10 192.168.1.10

Connections would be allowed from two machines with IP addresses 10.10.10.10 & from 192.168.1.10. Once the changes have been made, you need to restart the redis service to apply changes,

$ sudo systemctl restart redis

Conclusion

Hence, We have finished our practicals on how to install Redis on CentOS & RHEL. Please do send in any queries in below comment box.

Read Also : Top 20 Linux Find Command Practical Examples

Originally published at https://thecodecloud.in on December 18, 2020.

--

--

Er Ravindra Pawadia

Hi Guys, This is Ravi. I am AWS and Oracle Certified Solution Architect Associate. I love to write technical blogs on my blogging site https://thecodecloud.in .