If you are hosting your WordPress Website or any other web application on AWS Lightsail, which is a cheap yet powerful option for hosting with AWS infrastructure, and are now planning to make your website perform even better using Redis Server, then you are at the right place.
In this article we will learn, step by step, how to install the Redis server on your AWS Lightsail machine (this guide will work for other Linux machines too like Ubuntu, etc.)
If you have WordPress or LAMP setup on AWS Lightsail, then chances are high that you are using a Bitnami setup.
To start the installation process, connect to your server via SSH, so that we can run the installation commands. You will need root access to your server to run the below commands.
It's always advisable to upgrade the OS and related software before we install any new service. So run the following command:
sudo apt-get update
sudo apt-get upgrade
Run the following command to install the Redis server:
sudo apt-get install redis-server
Now, let's change a few basic configurations in the redis.conf file which is available here: /etc/redis/redis.conf
You can use nano editor or vim editor to open and edit this configuration file. We have to add the below two configuration lines to the configuration file:
maxmemory 256mb maxmemory-policy allkeys-lfu
We will restart the php-fpm service and start the Redis server.
sudo systemctl restart redis-server
and then run the following command:
sudo /opt/bitnami/ctlscript.sh restart php-fpm
Run the following command to see if redis is installed correctly and is working fine,
You should see such an output:
Redis server v=5.0.3 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=94145a25ce04923
The redis server by default uses the port number 6379, we can check if this port is being used or not by running the following command:
netstat -lpan | grep :6379
You will see the following output:
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN -
tcp6 0 0 ::1:6379 :::* LISTEN -
And we are done.
You can monitor the Redis server to see if it is running or not using the following command:
This installation guide is specific to AWS Lightsail which uses Bitnami service stack but it will most likely work for other Linux operating systems too like Ubuntu, CentOS, etc. If you face any error, or you are not able to understand anything, please feel free to share in the comment section below.