Are you looking for how to install Magento on AWS?

Magento is the most popular and leading platform for eCommerce websites. According to TrustBuilt, nearly 173k sites are using the Magento platform.

Magento is the first choice of many eCommerce developers because of its versatility and powerful performance. It offers limitless flexibility and endless scalability for store owners to build, design, and manage unique online experience.

However, the framework is scalable and reliable; the Magento platform requires an infrastructure that is also flexible and scalable.

And if you are looking for a highly flexible and secure cloud computing solution, you will find Amazon Web Services a perfect solution to host your online store.

Why Amazon Web Services?

Magento is an open-source platform, and it can run on shared hosting too.

However, if you are starting an eCommerce business, it is wise to have a secure and reliable hosting. Shared hosting is neither safe nor reliable.

Starting an eCommerce store on shared hosting is the first step taken wrong.

Dedicated hosting is the hosting where the users get total control over the resources. The store receives reliable and powerful support. However, the chances are low, but if anything happens with the dedicated server, the eCommerce store has to suffer.

This is not a problem with cloud hosting.

With cloud hosting, if your hosting encounters any unseen error, a site backup will take place of your existing site within seconds. The site resources are mirrored at a few locations in cloud hosting, and the copies come useful during redundancy time.

AWS is a leader when it comes to cloud hosting.

That’s why more and more merchants are moving towards AWS for their hosting requirements.

Let’s see how to install Magento on AWS Hosting.

The process is in three parts:

Creating the Server in AWS

Launching an instance on AWS

Follow the steps below to launch an instance on AWS.

First you need to set up an account on Amazon.

Now, navigate to AWS Management console and login into your account.

AWS management console

You will see the following screen:

select ec2 in management console

Select EC2 under the All Services.

If you can’t find it, search in the Find Services box.

It will load up the following screen.

open instance in ec2 dashboard

From the EC2 Dashboard, click on Launch Instance. (You can also View and Launch Instances from Instances in the left panel.)

Step 1: Choose an Amazon Machine Image (AMI)

Here, you can choose which Operating System you want to run on from the available templates. (We will be using Red Hat Enterprise Linux 8)

screencapture3 console aws amazon com ec2 v2 home 1589786536155 how to install magento on aws

Select your preferred operating system.

We selected the Linux because Magento runs on Linux. Magento is not supported on Windows or macOS. And most of the developers find the Linux OS more friendly.

Step 2: Choose an Instance Type

Instances are classified into a wide-variety to fit different requirements. You can select the type of example you need to work on and click Next.

screencapture4 console aws amazon com ec2 v2 home 1589787084641 how to install magento on aws

Now, we are taking the t2 micro (with only 1 GB Ram), because we are only installing Magento to show you the process.

Although, if you are planning to run an eCommerce store, get at least 2 GB RAM. Because that is the minimum RAM requirement of running the Magento 2 store.

Click on “Configure Instance Details.”

Step 3: Configure Instance Details

You can configure your instance here.

We can skip this step, as there is nothing to change here, unless if you have some particular requirement form the machine.

screencapture5 console aws amazon com ec2 v2 home 1589790449142 how to install magento on aws

Click on the Add Storage, and the next page will appear.

Step 4: Add Storage

screencapture6 console aws amazon com ec2 v2 home 1589800493111 how to install magento on aws

You can configure the storage size of your instance.

Since the default value of 10GB is enough, we will keep it as is and click next.

Step 5: Add Tags

We can skip this part as we don’t need any tags as of now.

We will move on to Configure Security Groups.

Step 6: Configure Security Group

Security Group is a set of firewall rules at the AWS Console end to control the traffic.

You will have to make sure that each IP/PORT we require is whitelisted here to ensure the functioning of the Application.

Since we are hosting a Magento Application, we will need port 80/443 for HTTP/HTTPS Connections, 22 for SSH, and 3306 for MySQL.

screencapture7 console aws amazon com ec2 v2 home 1589877864303 1 how to install magento on aws

Click on the Review and Launch to review your instance before launching it.

Step 7: Review Instance Launch

On the next page, you will see the details of your Instance on a single page.

Before launching, you have to set a key pair.

screencapture8 console aws amazon com ec2 v2 home 1589878093618 how to install magento on aws

It will prompt you to either choose a key-pair or create new ones. This is a critical step as you require the key to access your instance via SSH. Password Authentication is disabled by default on EC2 Instances, and only key-based authentication is allowed.

Here, we have created a new key-pair named “WebMagento” and Downloaded the key-pair and clicked on Launch Instances.

You should now be able to see a page showing the Launch Status from which you can move to View Instances.

screencapture9 console aws amazon com ec2 v2 home 1589878405122 how to install magento on aws

You will then be redirected to the EC2 Dashboard, where you can view and manage all your instances.

To login to the Instance via SSH, select the Instance.

screencapture10 console aws amazon com ec2 v2 home 1589886594045 how to install magento on aws

Click on Actions>Connect and follow the steps provided in the pop-up menu.

Copy the git bash code from the box and paste the code in the Git Bash.

Screenshot 11from 2020 05 19 17 00 15 how to install magento on aws

It will ask if you want to continue. Type Y, and you will enter.

Once done, you will be on your server.

Now you need to set the environment on the server for the Magento platform.

Setting up Hosting Stack

Now that we have created an instance, we can set up the Hosting Stack in the server.

For this, we need a Web Server(Nginx), Database Server(MySQL), and PHP(7.2), which is collectively called a Hosting Stack.

You can install the packages using the command below.

$ yum install -y nginx mysql-server php php-bcmath php-cli php-common php-fpm php-gd php-intl php-json php-mbstring php-mysqlnd php-pdo php-pecl-zip php-soap php-xml

Note: The PHP Extension requirements are available here.

#1 Start Nginx Web Server

# systemctl start nginx.service
# systemctl enable nginx.service

To Test if Nginx is running, you can try loading the public DNS of your AWS Instance (available in AWS>Ec2 Instances>Description.

You should be able to see a webpage as shown in the screenshot below.

Screenshot 12from 2020 05 21 10 15 57 how to install magento on aws

Configure Nginx

We need to add the below server blocks to Nginx configuration located in /etc/nginx/nginx.conf.

Search for the server block and replace it with the below template.

server {

Replace with:

server { server_name; listen 80; root /usr/share/nginx/html; error_log /var/log/nginx/webmagento_error.log; access_log /var/log/nginx/webmagento_access.log; location / { index index.php; try_files $uri $uri/ /index.php?$args; } location ~ .php/ { try_files $uri =404; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME /index.php; fastcgi_pass; }

Verify the configuration and restart Nginx Webserver.

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# systemctl restart nginx.service

2. Configure PHP-FPM

To find out where PHP-FPM is installed, execute the below command.

# rpm -ql php-fpm | grep php-fpm.d
Screenshot 13from 2020 05 21 10 22 43 how to install magento on aws

Move to the php-fpm.d directory and rename the default www.conf to something else.

# cd /etc/php-fpm.d
# mv www.conf www.conf_sample

We will then create a new conf with the below template.

# vi magento-php.conf [magento]
listen =
listen.allowed_clients = user = nginx
group = nginx
;The below values are related to the Process Manager governing PHP-FPM.
pm = ondemand
pm.process_idle_timeout = 10s
pm.max_children = 10 pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 20
pm.max_requests = 1000 request_terminate_timeout = 3600s

Start php-fpm process

# systemctl start php-fpm

To test if the PHP-FPM is serving PHP files, we can add a phpinfo page and try accessing it in the browser.

# cd /usr/share/nginx/html
# vi phpinfo.php

Add the below code.


Now access the page using the domain URL/phpinfo.php. You should see an info page like the one shown below.

Screenshot 14from 2020 05 21 11 32 29 how to install magento on aws

#3 Start and configure MySQL Service

# systemctl start mysqld.service
# systemctl enable mysqld.service
# mysql_secure_installation

Now when prompted, enter the values as shown below.

Enter current password for root (enter for none): Just press the Enter

Set root password? [Y/n]: Y
New password: Enter password
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

You’ve successfully configured MySQL now.

To test if MySQL is running, try logging in as Root using the below command.

# mysql -u root -p

Input password when prompted.

Screenshot 15from 2020 05 19 17 45 14 how to install magento on aws

We need to create a database, database user, and assign privileges. Login to MySQL as the root user and execute the below commands.

create database webmagento;
create user 'webmagento'@'localhost' identified by 'password';
grant all on webmagento.* to 'webmagento'@'localhost';
flush privileges;

Now test the logins by logging in as the newly created user.

mysql -u webmagento -p webmagento

Installing Magento

Now that we have installed and configured our hosting stack, we can proceed to install Magento on our Instance.

#1 Install Composer

# curl -sS <> | sudo php -- --install-dir=/usr/bin --filename=composer

#2 Download Magento

# cd /usr/share/nginx/html
# wget <>

Extract the contents

# tar xvfz 2.3.5.tar.gz

Move the contents to html directory and Set Permissions

# chown -R nginx.nginx . # find . -type f -exec chmod 644 {} \;
# find . -type d -exec chmod 755 {} \;
# find ./var -type d -exec chmod 777 {} \; # find ./pub/media -type d -exec chmod 777 {} \;
# find ./pub/static -type d -exec chmod 777 {} \;
# chmod 777 ./app/etc;
# chmod 644 ./app/etc/*.xml;

Install Magento from CLI

Use the below command to install the Magento from CLI

# php /usr/bin/composer install
Screenshot 16from 2020 05 21 13 48 15 how to install magento on aws
# bin/magento setup:install --base-url= \
--db-host=localhost --db-name=webmagento --db-user=webmagento --db-password=password \
--admin-firstname=Web --admin-lastname=Magento \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=0
Screenshot 17from 2020 05 21 13 48 46 how to install magento on aws

The admin URL will be generated and displayed in the results.

# php bin/magento setup:di:compile
Screenshot 18from 2020 05 21 13 49 00 how to install magento on aws

Include the Magento’s default configuration file to the nginx.conf file. Add the line below to the nginx.conf between the server block we previously added.

include /usr/share/nginx/html/nginx.conf.sample

Then restart the Nginx webserver.

We have now successfully installed Magento 2 on AWS.

You can now access the webpage using the URL, and the Admin page using the URL/<admin URL>

Screenshot 19from 2020 05 21 13 33 41 how to install magento on aws
Screenshot 20from 2020 05 21 13 35 25 how to install magento on aws

It’s done. Your Magento store is ready, and you can begin customizing the platform.

Is there any easy way to install Magento on AWS?

Yes, there is.

Getting Managed AWS Hosting is much more comfortable and valuable than this.

First of all, you only installed the Magento on the server.

The tasks of Magento hosting are far from over.

There will be updates, releasing every other week. Sometimes of the PHP, or MySQL, or even the Magento itself. You will soon find your self spending more and more time managing the hosting of Magento.

The time that you should use to scale your business will waste in the daily hosting tasks.

Right now, we only installed the empty Magento platform on the Server.

Think of setting up an online store with incoming traffic. Updating the store or stack could bring your store down if not done correctly.

Moreover, we did not mention many settings and optimization techniques that improve the Magento store’s loading speed. We have not installed any security apps and firewalls yet.

There are still so much to do in the AWS hosting. Everyday you will encounter a new type of issue.

That’s why merchants move to managed AWS hosting.

ServerGuy will manage your AWS Hosting, & we will migrate the store at no cost.

Advantage of Managed AWS Hosting of ServerGuy


We will quickly increase the resources in case of any sudden traffic hike. Your site will never go down under our managed AWS hosting.

Managed Server Security

Besides the AWS security, your store will get the firewalls and protection from the ServerGuy.

Our team proactively monitor the servers and protect the customers from every web threats and spam attacks.


We will never let the AWS bill you more than your site is consuming. With ServerGuy managed AWS hosting, you will only pay for the resources your store is using.

You can read how we reduced the AWS bill by 25% of one of our customer.

Seamless Support

We ensure the 15 minute response time. Our technical support is available 24/7/365 via live chat and ticket system.

Final Words

If you want to install Magento on AWS on your own, follow the steps in the post.

Or you can let the expert do this for you, while you focus on your business instead of technical stuff.

Posted by Editor