In this tutorial we will show you how to install and configuration Redis on Ubuntu 16.04. 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.
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:
Oct2015:07:10ubuntu-16redis-server: | `-._`-._ _.-'_.-' |
Oct2015:07:10ubuntu-16redis-server: `-._ `-._`-.__.-'_.-' _.-'
Oct 20 15:07:10 ubuntu-16 redis-server: `-._ `-.__.-' _.-'
Oct 20 15:07:10 ubuntu-16 redis-server: `-._ _.-'
Oct2015:07:10ubuntu-16redis-server:7207:M20Dec16:07:10.853# WARNING: The T
Oct2015:07:10ubuntu-16redis-server:7207:M20Dec16:07:10.853# Server started
Oct2015:07:10ubuntu-16redis-server:7207:M20Dec16:07:10.853# WARNING overco
Oct2015:07:10ubuntu-16redis-server:7207:M20Dec16:07:10.853# WARNING you have.
We will now test the Redis instance with some commands:
Congratulation’s! 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 web site.