Redis is widely used in-memory key-value store known for its flexibility, performance, and wide language support. In this post we will learn how to install and configure Redis on an Ubuntu 17.10 server.


For this setup we are using Ubuntu 17.10 latest as now Dec 2017.

root@srvu:~# lsb_release -d
Description:	Ubuntu 17.10
root@srvu:~# uname  -r

root@srvu:~# redis-server --version
Redis server v=4.0.6 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=61be49bb49fd3add


To get latest redis packages version, we are going to download it from redis website and compile it on Ubuntu machine mentioned below. But before so we should get redis packages and start compiling it on machine, we have to install build dependencies. So for this we have to install build-essentials and tcl for test our binaries.

In below commands, we are installing Build-essentials and tcl packages

# apt-get update
# apt-get install build-essential tcl

Download, Compile, and Install Redis

Further we could download,compile and install redis packages like below.

root@srvu:~# mkdir source
root@srvu:~# cd source/

Above we create source directory, so there would no pollution while compiling packages.Further we download redis package like below.

root@srvu:~/source# wget
--2017-12-13 12:09:08--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1755093 (1.7M) [application/x-gzip]
Saving to: ‘redis-stable.tar.gz’

redis-stable.tar.gz        100%[==============>]   1.67M   399KB/s    in 4.6s    

2017-12-13 12:09:13 (374 KB/s) - ‘redis-stable.tar.gz’ saved [1755093/1755093]

Build and Install Redis

Further we need to unzip it.

root@srvu:~/source# tar xzf redis-stable.tar.gz 
root@srvu:~/source# cd redis-stable/
root@srvu:~/source/redis-stable# ls
00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils

Now we need to compile it further.

root@srvu:~/source/redis-stable# make

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory '/root/source/redis-stable/src'

root@srvu:~/source/redis-stable/src# make install

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

As mentioned in above command output, we need to run make test

root@srvu:~/source/redis-stable/src# make test

All tests passed without errors!

Cleanup: may take some time... OK
make[1]: Leaving directory '/root/source/redis-stable/src'

Configure Redis

Now we need to configure redis server like mentioned below, in which first need copy redis.conf file.

As above compile directory has rediss.conf which need to copy in /etc/redis directory.

root@srvu:~/source/redis-stable# ls
00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils
root@srvu:~/source/redis-stable# mkdir /etc/redis

root@srvu:~/source/redis-stable# cp redis.conf /etc/redis/

Now need to edit redis.conf file. Although there are many configuration parameters in redis.conf file but we only need to edit below mentioned.

root@srvu:~# egrep "^dir|^supervised" /etc/redis/redis.conf 
supervised systemd
dir /var/lib/redis

Create Redis systemd unit file

Now we need to create systemd service file for redis service like mention below.

root@srvu:~# cat /etc/systemd/system/redis.service
Description=Redis In-Memory Data Store

ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown


Create Redis user, Group and Directory

Now need to create User and group for redis application.

root@srvu:~/source/redis-stable# useradd -r -M redis

Now we should create redis database directory which we had mentioned in redis configuration file.

root@srvu:~/source/redis-stable# mkdir /var/lib/redis
root@srvu:~/source/redis-stable# chown redis:redis /var/lib/redis/
root@srvu:~/source/redis-stable# chmod 770 /var/lib/redis/

Now we could start redis service as mentioned below.

root@srvu:~/source/redis-stable# systemctl start redis

root@srvu:~/source/redis-stable# systemctl status redis
● redis.service - Redis In-Memory Data Store
   Loaded: loaded (/etc/systemd/system/redis.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2017-12-13 13:59:27 IST; 1s ago
 Main PID: 17196 (redis-server)
    Tasks: 4 (limit: 4915)
   Memory: 1.1M
      CPU: 4ms
   CGroup: /system.slice/redis.service
           └─17196 /usr/local/bin/redis-server

Now we should enable redis service to start automatically on boot time

root@srvu:~/source/redis-stable/src#  systemctl enable redis
Created symlink /etc/systemd/system/ → /etc/systemd/system/redis.service.

So through this way we just install and configure redis on Ubuntu 17.10 machine.

Test Redis

Now we could test redis and verify whatever we did above is working as it should or not.

So first we are going to ping from redis-cli.

root@srvu:~/source/redis-stable/src# redis-cli> ping

Now we will run test as mentioned below.> set test "It's working!"
OK> get test
"It's working!"> exit

Summary:- This way Now we know , how to install, configure and test redis on Ubuntu 17.10 machine