AWS — How to Install Redis on EC2 Instance for Fast In-Memory Database

Shawn Shi
3 min readSep 3, 2018

UPDATED 2020/10/16:
- All commands have been updated so that this article is up-to-date!

I have recently installed Redis on our web server at work and used it as the session engine in order to improve the performance of our web application. Redis successfully improved the session time by 99.97% compared to our old file engine. I’d like to share a quick and simple way to install Redis on your AWS EC2 server. If it is of interest to the audience, I will share a more complete and secure way to install, protect, and fine-tune Redis for production use.

Redis Logo (Image source:

Step 1 — Connect to your EC2 instance through SSH.
For demonstration purpose, I have created a free AWS Linux AMI instance. If you want some step-by-step details, please refer to section #2 in my other article AWS — How to Host a LAMP Web Application Server on AWS EC2 For Free.

Screenshot by Author

Step 2 — Run the following commands line by line to install Redis and dependencies.

sudo yum -y install gcc make # install GCC compiler
cd /usr/local/src
sudo wget
sudo tar xvzf redis-stable.tar.gz
sudo rm -f redis-stable.tar.gz
cd redis-stable
sudo yum groupinstall "Development Tools"
sudo make distclean
sudo make
sudo yum install -y tcl

UPDATE 2020/10/16: Thanks to the comment from Thusith, line ‘sudo yum groupinstall “Development Tools”’ is added.

Step 3 — Run a test and make sure Redis is correctly installed.

sudo make test

It will take a couple of minutes to go through all the tests. But once it is done, you should be able to see a smile face, \o/, and a message saying “All tests passed without errors!” like below:

Screenshot by Author

Step 4 — Copy both the Redis server and the command line interface (CLI) executables into proper places, using the following commands.

Shawn Shi

Senior Software Engineer at Microsoft. Ex-Machine Learning Engineer. When I am not building applications, I am playing with my kids or outside rock climbing!