How to Install Redis on Ubuntu 18.04

r00t May 20, 2018

Install Redis on Ubuntu 18.04

In this tutorial well learn how to install Redis on Ubuntu 18.04. We will also install and configure its prerequisites. Redis is an open source multi-platform data store written in ANSI C, that uses datasets straight from memory achieving very high performance. It supports different programming languages, including Lua, C, Java, Python, Perl, PHP and many others. It’s founded on ease, about 30k lines of code which do “few” things, but do them well. Despite you work on memory, persistence can exist and it has a fairly decent support for high availability and clustering, which does great in keeping your data secure.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 LTS Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Redis on Ubuntu 18.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing Redis on Ubuntu 18.04.

Run the following command to install Redis Server on your Ubuntu system:

sudo apt-get install redis-server

If you are planning on utilizing Redis as an object cache for WordPress or any other PHP-based application, you need to install another package also:

sudo apt-get install php-redis

After which you have to enable Redis to start on system boot. Also restart Redis service once:

sudo systemctl enable redis-server.service

Step 3. Configure Redis Caching.

We’ll open up its default configuration file to ensure that Redis is bound to the local IP. Unless you are running a full Redis cluster, which is beyond the scope of this guide, this is the best way to secure your Redis store from unauthorized access:

sudo nano /etc/redis/redis.conf

Search for the line that begins with “bind”, changing it as follows:


Also, You can increase max memory limit as per available on your server. There are a lot more options to configure, this can be accessed on the redis website:

maxmemory 256mb
maxmemory-policy allkeys-lru

Save your changes and restart the Redis service to reload our configuration changes:

sudo systemctl restart redis-serve

Redis should now be operational. To test, we’ll connect locally and enter some data:

root@redis-nodes:~# redis-cli> set besthost ""
OK> get besthost

Congratulation’s! You have successfully install and configure Redis on your Ubuntu 18.04 LTS (Bionic Beaver) server. Thanks for using this tutorial for installing Redis on Ubuntu system.


The Tags:

Leave a Comment

Comments are closed.