Installing Redis from Chris Lea's PPA

For quite a while the Debian/Ubuntu package for redis-server has been behind the official Redis releases.

Whilst this doesn’t matter in most cases, it does if you want to use any of the new features of Redis. It also does if you just like being on the latest version which I do.

I have an older server which is running Ubuntu 16.04 (Xenial) and a newer one running Ubuntu 18.04 (Bionic). The old one running Xenial is currently running Redis v5 as shown:

$ apt-cache policy redis-server
  Installed: 5:5.0.4-1chl1~xenial1
  Candidate: 5:5.0.4-1chl1~xenial1
  Version table:
 *** 5:5.0.4-1chl1~xenial1 500
        500 xenial/main amd64 Packages
        100 /var/lib/dpkg/status
     2:3.0.6-1ubuntu0.3 500
        500 xenial-updates/universe amd64 Packages
        500 xenial-security/universe amd64 Packages
     2:3.0.6-1 500
        500 xenial/universe amd64 Packages
        500 xenial/universe amd64 Packages

As you can also see it is being fetched from Chris Lea’s PPA. On the newer Bionic you can see that the candidate for installation is Redis v4:

$ apt-cache policy redis-server
  Installed: (none)
  Candidate: 5:4.0.9-1ubuntu0.1
  Version table:
     5:4.0.9-1ubuntu0.1 500
        500 bionic-updates/universe amd64 Packages
        500 bionic-security/universe amd64 Packages
     5:4.0.9-1 500
        500 bionic/universe amd64 Packages

So, let’s fix this so we can get Redis v5 on the new server. The rest of this post then is mostly to remind myself where I got these instructions, and what I did.

Firstly, let’s head to Chris Lea’s PPS for Redis Server, and here we can see the following instructions:

$ sudo add-apt-repository ppa:chris-lea/redis-server
$ sudo apt-get update

So let’s do this. Note that we currently have the following two package repos added to our system already:

$ ls -l /etc/apt/sources.list.d/
total 12
-rw-r--r-- 1 root root 134 Jun  5  2018 certbot-ubuntu-certbot-bionic.list
-rw-r--r-- 1 root root 108 Jun  5  2018 nodesource.list

Okay, we’ll add the repo now:

$ sudo add-apt-repository ppa:chris-lea/redis-server
[sudo] password for chilts:
 Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
 More info:
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Get:7 bionic InRelease [15.4 kB]
Get:8 bionic/main amd64 Packages [1012 B]
Get:9 bionic/main Translation-en [584 B]
Fetched 17.0 kB in 1s (18.8 kB/s)
Reading package lists... Done

Now we can see a new file in the apt sources list:

$ ls -l /etc/apt/sources.list.d/
total 20
-rw-r--r-- 1 root root 134 Apr  6 07:56 certbot-ubuntu-certbot-bionic.list
-rw-r--r-- 1 root root 148 Apr  6 07:56 chris-lea-ubuntu-redis-server-bionic.list
-rw-r--r-- 1 root root 108 Apr  6 07:56 nodesource.list

$ cat /etc/apt/sources.list.d/chris-lea-ubuntu-redis-server-bionic.list
deb bionic main
# deb-src bionic main

Do an update as usual:

$ sudo apt-get update
Hit:7 bionic InRelease
Reading package lists... Done

And now we can see we have a newer redis-server candidate:

$ apt-cache policy redis-server
  Installed: 5:4.0.9-1ubuntu0.1
  Candidate: 5:5.0.4-1chl1~bionic1
  Version table:
     5:5.0.4-1chl1~bionic1 500
        500 bionic/main amd64 Packages
 *** 5:4.0.9-1ubuntu0.1 500
        500 bionic-updates/universe amd64 Packages
        500 bionic-security/universe amd64 Packages
        100 /var/lib/dpkg/status
     5:4.0.9-1 500
        500 bionic/universe amd64 Packages

Wahoo! Now to install it and we can Redis away:

$ sudo apt-get install redis-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
Suggested packages:
The following packages will be upgraded:
  redis-server redis-tools
2 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Need to get 923 kB of archives.
After this operation, 2429 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 bionic/main amd64 redis-server amd64 5:5.0.4-1chl1~bionic1 [79.5 kB]
Get:2 bionic/main amd64 redis-tools amd64 5:5.0.4-1chl1~bionic1 [844 kB]
Fetched 923 kB in 1s (1071 kB/s)
(Reading database ... 96119 files and directories currently installed.)
Preparing to unpack .../redis-server_5%3a5.0.4-1chl1~bionic1_amd64.deb ...
Unpacking redis-server (5:5.0.4-1chl1~bionic1) over (5:4.0.9-1ubuntu0.1) ...
Preparing to unpack .../redis-tools_5%3a5.0.4-1chl1~bionic1_amd64.deb ...
Unpacking redis-tools (5:5.0.4-1chl1~bionic1) over (5:4.0.9-1ubuntu0.1) ...
Setting up redis-tools (5:5.0.4-1chl1~bionic1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.17) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up redis-server (5:5.0.4-1chl1~bionic1) ...
Installing new version of config file /etc/redis/redis.conf ...

And we’re all good to go:

$ redis-cli> keys *
(empty list or set)