This Magento AMI walks you through using the Magento auto-installer script (magento_installer.sh) to deploy a Magento site with Apache/Nginx, MySQL, and SSL on an AWS EC2 instance.
Prerequisites For Magento AMI Installer
This AMI comes pre-configured with all required software and Magento source code. Before using the installer, ensure the following:
- You launch the EC2 instance using the Magento AMI.
- The auto-installer script is available at: /home/ubuntu/magento_installer.sh
- The system pre-installs and configures Apache/Nginx, MySQL, Elasticsearch, OpenJDK 17, PHP and the required PHP extensions.
- The system has already placed the Magento source code under: /var/www/html/ or /var/www/html/magento2/
- DNS: Your domain must point to the EC2 public IP (A record set)
Installation Steps
Step 1: Run the Script
|
1 |
sudo bash magento_installer.sh |
The system will prompt you to enter the following inputs:
- MySQL Credentials
- Database name (e.g. magento_db)
- Database user (e.g. magento_user)
- Database password
Additionally, the script will create the DB and user automatically if they don’t exist.
- Domain Validation
- Enter your domain (e.g. example.com)
- The script will check if the domain points to this server’s public IP.
If domain matches, installation proceeds.
If the domain doesn’t match, the system will ask you to try again.
Step 2: Magento Installation
Once the domain check passes:
- Magento setup will run silently in the background.
- A spinner will indicate progress.
- It typically takes few minutes.
Step 3: Apache/Nginx Virtual Host & SSLPath
- A VirtualHost config will be created for port 80 and 443.
- Apache/Nginx will reload.
- Let’s Encrypt SSL will be automatically issued using Certbot.
- Your site will be accessible over HTTPS.
Step 4: Credentials
At the end, the following will be saved at the mentioned directory
—–> /home/ubuntu/magento_admin_credentials_<your-domain>.txt
Contents include:
- Magento Store URL (e.g. https://example.com)
- Magento Admin URL (e.g. https://yourdomain.com/admin_xxxxxx)
- Magento Admin Username & Password
Example Output
Magento 2.4.2 + SSL Installed Successfully!
Store URL: https://example.com
Admin URL: https://example.com/admin_Kf93pL
Admin User: admin
Admin Password: PASSWORD
Step 5: Disable 2-Factor-Authentication
After login to admin page run the below command to disable two_factor_authentication
for Apache:
|
1 2 |
sudo cd /var/www/html/ sudo php bin/magento module:disable Magento_TwoFactorAuth |
for Nginx:
|
1 2 |
sudo cd /var/www/html/magento2/ sudo php bin/magento module:disable Magento_TwoFactorAuth |