How to install Magento 2 on AWS linux?

Amazon web service (AWS) is undoubtedly leading hosting infrastructure provider on the earth for various verticals. Combination of AWS & Magento 2 is widely used by leading enterprise customers. So today, let's learn how to setup Magento 2 instance on AWS server.

Amazon Developer Console

Go to Amazon and set up a free account ( for a new account aws provide free tier function for 1 year). Now, navigate to services Menu from AWS top bar. You will see the following screen:

Aws Console

Select EC2 service. Search it in Find Services if you are not seeing in page and you will get it. Click on it. Now you will see the below screen:

Launch Instance

Click on Launch Instance.

Then you will see the below screen and select any Linux instance. Here we are selecting Ubuntu server for Magento as below screen

Select Linux server for Magento

Select the Ubuntu server as an above screen. Most developers are using Linux server to run PHP based applications with apache or Nginx server. 

As per Magento document Magento 2 system requirements you need at least 2GB of RAM. However, I suggest having 4GB RAM for the production site and if you are doing this for the dev version of the site then 2GB is fine. however, you can change the instance type anytime after launching the EC2 instance.

Therefore, you must:

Select 'Type t2 small' for the dev site

Select 'Type t2 medium' for the production site

Note that any of this type not eligible for the free tier.

How to select instance type in aws

Click on the Next Button “Configure Instance Details”. Now you will see the below the screen and there is nothing more to change anything in the default configuration.

Setup configuration in ec2 instance

Proceed to the next step to add storage as below screen. It is default selected 8GB which is enough but as per your Magento data if you need more then write the required space in the configuration

Storage configuration in AWS ec2

Proceed to the next step to add tags as below screen

how to add tags in aws ec2 instance

You can add a tag to identify your instance in aws if there are multiple instances. In the above screen written Name tag to test instance. Same like you can add any information like environment = dev or production etc so you know what purpose of this instance. Now click on the configure security group button which is important to set up to allow access from the web.

Create security group for Magento in AWS

Here you have to create a new security group as above snap and given name and description. And allow this instance to access from web port 80 (HTTP) and 443(HTTPS). As we are going to set up Magento in this instance and it is must require to allow from web port. Additionally, if you allow from some specific IP then you can configure in source column for each port. On-screen it is 0.0.0.0/0, which means to allow for anyone to access this instance through the allowed port.

Click on review and launch, you will see the below screen

Review ec2 configuration for magento

On this screen, you can review all configurations selected so after reviewing it click on launch it will show a popup to generate or select an existing key to connect this instance.  select Create a new keypair so must need to download the key after giving the name of the key which will not available again to download or recover so keep safe this key which will use to connect this instance using putty or any third party application.

Generate key and download it for SSH connect

Now click on the Launch button it will appear below the screen 

launch instance

Click on “View Instance” it will show an instance dashboard where you can see your instance as initializing state as below snap.

intializing ec2 instance in AWS

Wait for a while and refresh the screen and see the instance status

active instance

Now you can connect this instance using a generated ssh key and using git or putty software.