How to Set Up Magento on AWS Without Using AMI
If you are a Magento developer, chances are you may have performed many local setups! You may have also set up Magento development services on 
If you are a Magento developer, chances are you may have performed many local setups! You may have also set up Magento development services on 
If you are a Magento developer, chances are you may have performed many local setups! You may have also set up Magento development services on many other scratch servers. If yes, Magento on AWS ec2 instance is something that you need to look out for. As we all know AWS has many AMIs that we can use to set up Magento on the EC2 instance but that can be expensive on the budget.
In this article, we will get to know about Magento on AWS ec2 environment variables a bit and how to set up Magento from scratch without using any AMI. This also helps us create our own Magento AMI through which we can create many Magento setups for the future and that too in just 5 to 10 minutes. So let's get started with it!
Create an EC2 instance
Firstly start creating an EC2 instance in your AWS account. Then, get the server up and running. Also, open port 80 for all IP addresses in the security group, or else the store won't be accessible. Now SSH into the server using the generated key file.
Root user login
We need to log in to the root user to avoid any permission issues. The below command switches you to a root user:
sudo su
Install PHP
Execute the below commands to update system packages and install PHP 7.4
yum update
yum install amazon-linux-extras
amazon-linux-extras | grep php
amazon-linux-extras enable php7.4
yum clean metadata
Required PHP Extensions
Install the required PHP extensions. You can review all the required extensions here
yum install php-cli php-pdo php-fpm php-json php-mysqlnd
yum install php php-{dom,simplexml,curl,intl,xsl,mbstring,zip,xml}
yum install php-{pdo,mysqlnd,opcache,gd,devel,bcmath,json,iconv,soap}
yum install php-sodium
Install Apache (httpd)
Execute the below commands to install, enable and start the apache. Also, check the status of the apache using the status command:
yum install -y httpd httpd-tools mod_ssl
systemctl enable httpd
systemctl start httpd
systemctl status httpd
Install Mariadb
Execute the below commands to get the required version of the MariaDB. Add it to the repository list and install it
yum -y update
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --os-type=rhel --os-version=7 --mariadb-server-version=10.4
sudo rm -rf /var/cache/yum
sudo yum makecache
sudo yum repolist
sudo yum install MariaDB-server MariaDB-client
sudo systemctl enable --now mariadb
systemctl status mariadb
Mariadb-secure-installation
Below configurations is to be done during the installation of the MariaDB:
Enter current password for root (enter for none):
You can just hit enter here, as this is a fresh setup of MariaDB. If you already have MariaDB installed and now if you are upgrading/ downgrading then enter the existing root password.
Switch to unix_socket authentication [Y/n] n
Next, set a new password to the root user.
Change the root password? [Y/n] y
New password:
Re-enter new password:
After this, the system will ask you to remove the anonymous users.