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
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 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
     2:3.0.6-1ubuntu0.3 500
        500 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages
     2:3.0.6-1 500
        500 http://mirrors.digitalocean.com/ubuntu xenial/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu 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
redis-server:
  Installed: (none)
  Candidate: 5:4.0.9-1ubuntu0.1
  Version table:
     5:4.0.9-1ubuntu0.1 500
        500 http://mirrors.digitalocean.com/ubuntu bionic-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
     5:4.0.9-1 500
        500 http://mirrors.digitalocean.com/ubuntu 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: https://launchpad.net/~chris-lea/+archive/ubuntu/redis-server
Press [ENTER] to continue or Ctrl-c to cancel adding it.

...etc...
Get:7 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic InRelease [15.4 kB]
Get:8 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic/main amd64 Packages [1012 B]
Get:9 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu 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 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic main
# deb-src http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic main

Do an update as usual:

$ sudo apt-get update
...etc...
Hit:7 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic InRelease
Reading package lists... Done

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

$ apt-cache policy redis-server
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 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic/main amd64 Packages
 *** 5:4.0.9-1ubuntu0.1 500
        500 http://mirrors.digitalocean.com/ubuntu bionic-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
        100 /var/lib/dpkg/status
     5:4.0.9-1 500
        500 http://mirrors.digitalocean.com/ubuntu 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:
  libjemalloc1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  redis-tools
Suggested packages:
  ruby-redis
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 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic/main amd64 redis-server amd64 5:5.0.4-1chl1~bionic1 [79.5 kB]
Get:2 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu 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
127.0.0.1:6379> keys *
(empty list or set)