Install Redis Server on Ubuntu 16.04

In this tutorial we are going to learn how to install redis on Ubuntu Linux. For this tutorial I am going to use Ubuntu Server 16.04.

To install Redis on Ubuntu Server, First update the apt source list, then install the redis-server package.

sudo apt-get update
sudo apt-get install redis-server

Ubuntu redis installation includes two main components, redis-server and redis-cli.

The redis-server is the actual Redis data store or the database and redis-cli is the command line tool that can use to perform redis commands.

To verify the redis server installation, Type:

redis-server --version

View the status of the redis service with systemctl command.

systemctl status redis.service
Redis Server status on Ubuntu 16.04

By default, Redis Server runs on TCP port 6379.

Connect to the Redis Database Server

To connect to the redis server on Ubuntu, type:

redis-cli

To access a redis server on a remote computer, we need to use -h option.

redis-cli -h 192.168.1.10

Allow Remote Access to the Database Server

By default redis server on Ubuntu run on the loopback interface which means server cannot be accessed from a remote computer. To allow remote access do the following steps.

Open the main configuration file 'redis.conf':

vim /etc/redis/redis.conf

Find the line that reads 'bind 127.0.0.1' and Replace it with the following line.

bind 0.0.0.0

Restart the redis service:

systemctl restart redis.service