---
title: "How to Setup Redis for Magento 2 on EC2 server?"
url: "https://magecomp.com/blog/setup-redis-for-magento-2-on-ec2-server/"
date: "2020-10-05T18:50:25+00:00"
modified: "2020-10-05T18:50:25+00:00"
author:
  name: "Gaurav Jain"
  url: "https://magecomp.com/"
categories:
  - "Magento Tutorials"
word_count: 434
reading_time: "3 min read"
summary: "In this blog, I will illustrate How to Setup Redis for Magento 2 on an EC2 server. Make sure you have visited previously published illustration fo Magento 2 Configuring Cloudfront CDN for Nginx Ser..."
description: "Redis is an open-source high-performance database, in-memory data structure store and very popular. Learn How to Setup Redis for Magento 2 on EC2 server."
keywords: "Magento Tutorials"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to Create a Catalog Price Rule in Magento 2?"
    url: "https://magecomp.com/blog/create-a-catalog-price-rule-magento-2/"
  - title: "How to Change the Magento 2 Encryption Key via Admin Dashboard?"
    url: "https://magecomp.com/blog/change-the-magento-2-encryption-key-via-admin-dashboard/"
  - title: "How To Configure Shipment Emails In Magento 2?"
    url: "https://magecomp.com/blog/configure-shipment-emails-magento-2/"
---

# How to Setup Redis for Magento 2 on EC2 server?

_Published: October 5, 2020_  
_Author: Gaurav Jain_  

![How to Setup Redis for Magento 2 on EC2 Server](https://magecomp.com/blog/wp-content/uploads/2020/10/How-to-Setup-Redis-for-Magento-2-on-EC2-Server-1024x512.webp)

In this blog, I will illustrate How to Setup Redis for Magento 2 on an EC2 server. Make sure you have visited previously published illustration fo [**Magento 2 Configuring Cloudfront CDN for Nginx Server**](https://magecomp.com/blog/magento-2-configuring-cloudfront-cdn-for-nginx-server/). Let’s Get Started?
You can follow these steps to [**Improve Magento 2 performance with AWS CloudFront**](https://magecomp.com/blog/improve-magento-2-performance-with-aws-cloudfront/)**☁️.**

## What is Redis?
Mainly, we can say that redis is an in-memory data structure store. It is well known because it’s a high-performance database and it’s open source. It is very prevailing within the [**Magento Developers**](https://magecomp.com/hire-magento-developer.html)?‍?. And there are lots of applications that use redis directly or indirectly.
## Why is Redis Fast?
Here, redis utilizes the memory to store the data. The whole data set means the Memcached is stored in-memory that means it is exceedingly fast. According to all the performances, we can conclude that redis is a remarkable selection if you need an exceedingly scalable data storage that is collectively shared by more than one process or multiple servers.
## Steps to Setup Redis for Magento 2 on EC2 server?:
**Step 1:** Install redis using the below command
```
Sudo apt-get install redis-server
```

**Step 2:** Utilize the below code to add it to the start services.
```
sudo update-rc.d redis-server defaults
```

**Step 3:** After the above steps we will move forward to secure it:
```
sudo nano /etc/redis/redis.conf
```

**Step 4:** Now open the config file and assure that the binding line is not commented. Also, uncomment the password line by entering a secure password as demonstrated below.
```
...

bind 127.0.0.1 ::1

...

...

# requirepass foobared

requirepass replacewithyourpassword
```

**Step 5:** Now we will create a powerful and secured password by utilizing the below-given command
```
openssl rand 60 | openssl base64 -A
```

**Step 6:** Now, this step is very essential because this password could be brute-forced.
At last restart the service
```
sudo systemctl restart redis.service
```

After the above implementation, we have successfully installed the redis and also secured the same. Now we will be required to enable it in Magento to follow the below-given commands for that. Make sure you haven’t forgotten to enter your redis password in the command else you will face difficulties by getting 500 errors.
```
bin/magento setup:config:set — session-save=redis — session-save-redis-host=127.0.0.1 — session-save-redis-log-level=3 — session-save-redis-db=2 — session-save-redis-password replacewithyourpassword
```

For more information check official Magento Developer Docs: [Use Redis for session storage](https://devdocs.magento.com/guides/v2.4/config-guide/redis/redis-session.html)

There it goes. You have cached your all sessions with redis successfully.
## Conclusion:
Hopefully, all are able to Setup Redis for Magento 2 on the EC2 server successfully by implementing the above-given illustration. In case of any difficulties you face in the above implementation then let me know in the comment section below I will be happy to help.
Till then Stay Safe and Keep Developing
**Happy Configuring?.**


---

_View the original post at: [https://magecomp.com/blog/setup-redis-for-magento-2-on-ec2-server/](https://magecomp.com/blog/setup-redis-for-magento-2-on-ec2-server/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-12 11:45:03 UTC_  
