In this tutorial we’ll learn how to install Redis on Ubuntu 16.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 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install Redis on Ubuntu 16.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.
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 installing, check if Redis Server is working or not with command:
sudo systemctl status redis-server
Step 3. Configure Redis.
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:
Save your changes and restart the Redis service to reload our configuration changes:
sudo systemctl enable redis-server 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 127.0.0.1:6379> set besthost "myvpsource.net" OK 127.0.0.1:6379> get besthost "myvpsource.net"
Congratulation’s! You have successfully install and configure Redis on your Ubuntu 16.04 server. Thanks for using this tutorial for installing Redis on Ubuntu system.