Signup/Sign In

How to Install Redis Server on AWS Lightsail?

Posted in Cloud   LAST UPDATED: SEPTEMBER 3, 2021

    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.

    Install redis on lightsail

    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.

    Install Redis Server:

    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.

    1. Start by running the basic Update:

    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

    Then run,

    sudo apt-get upgrade

    2. Install Redis Server

    Run the following command to install the Redis server:

    sudo apt-get install redis-server

    3. Update some basic Config:

    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

    4. Now Restart the Services

    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

    5. Verify Redis is running

    Run the following command to see if redis is installed correctly and is working fine,

    redis-server --version

    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.

    6. Monitor Redis Server

    You can monitor the Redis server to see if it is running or not using the following command:

    redis-cli monitor

    Conclusion:

    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.

    You may also like:

    About the author:
    I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight
    Tags:RedisHowToInstallation Guide
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS