Setting up Magento on a cloud server requires careful configuration to ensure smooth development and deployment. This comprehensive guide will walk you through the process of configuring an AWS EC2 instance, installing Docker, and deploying Magento 2.4.2. Follow these steps to create a robust development environment.
Connect to the Server:
ssh -i "AdobeCommerce-Dev.pem" ec2-user@<IP>
Update the Server:
sudo yum update -y
Install Docker:
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker <username> # Replace `<username>` with your username
docker info
Unzip Files:
sudo yum install unzip
unzip <folder_name>
Install Git:
sudo yum install git
Reset Docker Images:
docker system prune --volumes
Remove Directory:
sudo rm -rf <dir>
Clone the Git Repo:
git clone https://github.com/RayUjjal/magento2.git
Create .env File:
Build and Start Docker Containers:
docker-compose build
docker-compose up
Access Docker PHP Terminal:
docker exec -it <container_image_name> bash
Magento Installation:
cd var/www/html
composer create-project --repository-url=https://repo.magento.com/magento/project-community-edition <project-dir>
File Permissions:
cd /var/www/html/magento_hamilton
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data .
chmod u+x bin/magento
Magento Installation Commands:
bin/magento setup:install --base-url='<baseurl>' --db-host=db --db-name=<db-name> --db-user=<db-user> --db-password=<db-pass> --admin-firstname=<firstname> --admin-lastname=<lastname> --admin-email=<email id> --admin-user=<username> --admin-password=<password> --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=search --elasticsearch-port=<es port>
PWA Metapackage Installation:
composer config minimum-stability dev
composer config repositories.ext path "./ext/*/*/*"
composer require magento/pwa
Install Goomento Page Builder:(optional)
composer require goomento/module-page-builder
php bin/magento module:enable Goomento_PageBuilder
Enable Magento Modules:
php bin/magento module:enable --all
Disable Two-Factor Authentication:
php bin/magento module:disable Magento_TwoFactorAuth
Reindexing and Cache Clear:
php bin/magento indexer:reindex
php bin/magento cache:flush
Magento Admin URL:
Database Dump:
mysqldump -u <db user> -p <db password> > <filename>.sql
sudo docker cp -a <docker-container-name>: <filename>.sql /home/ec2-user/<folder path>
Magento Module Enable/Disable:
bin/magento module:enable <Module1>
bin/magento module:disable <Module1>
php bin/magento setup:upgrade
Magento Deploy Mode:
bin/magento deploy:mode:set developer
Cron Jobs:
crontab -l
bin/magento cron:install
bin/magento cron:run
Congratulations! You have successfully set up Magento 2.4.2 on AWS EC2 using Docker. This guide covers the essential steps for a seamless installation and configuration process. Keep this handy for future reference, and happy developing!