How To Install Redis on Ubuntu 16.04 LTS

Install Redis on Ubuntu 16.04 LTS

In this tutorial we will show you how to install  Redis on Ubuntu 16.04 LTS. For those of you who didn’t know, Redis is an open-source, BSD licensed, 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. Redis also supports datatypes such as Transitions, Publish and Subscribe. ‘Redis ’ is considered more powerful than ‘Memcache’ . It would be smart to bring ‘Redis’ into practice and put ‘Memcache’ down for a while.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Redis on a Ubuntu 16.04 LTS (Xenial Xerus) server.

Install Redis on Ubuntu 16.04 LTS

Step 1. First, make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

Step 2. Installing Redis on Ubuntu 16.04.

Installing Redis on an Ubuntu is simple. Run the command below to install Redis on your machine:

Redis provide PHP extension to work with PHP. Here we will cover installation of Redis Extension of PHP from source compilation and using apt repository. Following command will install and setup Redis extension with PHP:

Step 3. Configure Redis Cache on Ubuntu 16.04.

To configure Redis as a cache you need to edit the /etc/redis/redis.conf file:

To configure the max memory for Redis as well as how Redis will select what to remove when the max memory is reached, add the following lines at the end of the file:

Save and close the file, then restart the Redis service:

Step 4. Starting and Testing the Redis.

We will start and check the status of the Redis with the below commands:

We will now test the Redis instance with some commands:

Congratulations! You have successfully installed Redis. Thanks for using this tutorial for installing Redis on your Ubuntu 16.04 system. For additional help or useful information, we recommend you to check the official Redis website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!