Magento 2 install local or remote SSH environment using Docker and Visual Studio CODE

ssh -i *****.pem ec2-user@3.137.***.***
curl -s | sudo bash
sudo chmod -R 777 /var/run/docker.sock
sudo yum install wget,git,htop -y
sudo yum install mc -y
mc -b
docker pull genaker/magento2-project

One project, one image, one container!

Supervisor: A Process Control System

docker run --name magento2 -d -p 80:80 genaker/magento2-project#OR you can mount magento root as a volume on a host file system if you need new magento installation docker run --name magento2 -d -p 80:80 -p 443:443 -v /tmp:/shared -v /var/www/html/magento:/var/www/html/magento genaker/magento2-project
docker exec -it magento2 bash
supervisorctl status
supervisorctl tail -f redis stdout
supervisorctl start redis
docker exec -it magento2 /var/www/html/magento/bin/magento config:set web/unsecure/base_url "http://18.222.***.***/"

Visual Studio Code Remote — Containers

Visual Studio Code Remote — SSH

Host Magento2
HostName 18.222.***.***
User ec2-user
IdentityFile {path to the pem file}
composer require genaker/module-react-emojigame
bin/magento setup:upgrade
rm -rf generated/*
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
# install dockercurl -s | sudo bashsudo chmod 666 /var/run/docker.sock# Run magento container 
docker run --name magento2 -d -p 80:80 genaker/magento2-project
# check docker running containers
docker ps
# change Magento URL to your remote server IP addres (optional)docker exec -it magento2 /var/www/html/magento/bin/magento config:set web/unsecure/base_url "http://***.***.***.***/"# Cahek Magento web sitecurl -I http://***.***.***.***/
# Connect to the Mageto Dockerdocker exec -it magento2 bash# go to magento folder cd /var/www/html/magento
docker run --name magento2-my-second-project -d -p 666:80 genaker/magento2-project## set new url with the port:docker exec -it magento2-my-second-project /var/www/html/magento/bin/magento config:set web/unsecure/base_url "http://***.***.***.***:666/"
docker stop  magento2-my-second-project
docker exec -it magento2 bash
cd /var/www/html/magento
git clone -f magento2-sample-data/dev/tools/build-sample-data.php -- --ce-source=.bin/magento setup:upgradebin/magento setup:static-content:deploy -fbin/magento setup:di:compile

Committing Changes to the Docker Registry

Modify the MAgento Container

docker ps -a

Commit Changes to Image

docker commit [CONTAINER_ID] [new_image_name]
docker commit 62e0302eee0c magento-react# check images
docker images

Pushing Docker image

docker login
docker image tag magento-react genaker/magento-react:latest 

Pushing a Docker container image to Docker Hub

$ docker push <hub-user>/<repo-name>:<tag>
docker push genaker/magento-react
docker run --name magento2 -d -p 80:80 -p 443:443 -v /tmp:/shared  genaker/magento-react
docker run --name magento2 -d -p 80:80 -p 443:443 -v /tmp:/shared -v /var/www/html/magento:/var/www/html/magento genaker/magento2-projectcd /var/www/html
rm -rf magento
COMPOSER_MEMORY_LIMIT=-1 composer create-project --repository-url= magento/project-community-edition magento# or use git than you need git clone && composer install mysql -e 'drop database magento2';
mysql -e 'create database magento2';
cd magentobin/magento setup:install --base-url=http://***.**.*.** --db-host=localhost --db-name=magento2 --db-user=magento --db-password=magento --admin-firstname=Magento --admin-lastname=User --admin-user=admin --admin-password=admin123 --backend-frontname=admin --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1; \sudo chmod -R 777 var/ generated/ pub/media/ pub/static;php -d"memory_limit=-1" bin/magento sampledata:deploy# we need reload becouse opcache timestamp validation is off supervisorctl restart php-fpm# Change to SSL/HTTPS and domainbin/magento config:set web/secure/base_url this magento bag you basicaly must set unsecure/base_usr also or admin will not work
bin/magento config:set web/unsecure/base_url
bin/magento config:set web/secure/use_in_frontend 1bin/magento config:set web/secure/use_in_adminhtml 1# Point your domain to your IP addres or Load ballancer
php bin/magento deploy:mode:set production
nano /etc/php.d/10-opcache.ini
;opcache.validate_timestamps = 0
supervisorctl restart php-fpm

Set Up Permissions

find . -type f -exec chmod 644 {} \;find . -type d -exec chmod 755 {} \;chmod -Rf 775 varchmod -Rf 775 pub/staticchmod -Rf 775 pub/mediachmod 775 ./app/etcchmod 644 ./app/etc/*.xmlchmod -Rf 775 bin
tail -f var/log/exception.log
tail -f var/log/system.log
tail -f /var/log/php-fpm/www-error.log
sudo chmod -R 775 /var/www/html/magento/*
mkdir -p app/design/frontend/Genaker/theme-react-luma/
cd app/design/frontend/Genaker/theme-react-luma/
git clone .
mkdir -p app/code/React/React
cd app/code/React/React/
git clone .
mkdir -p app/code/ReactLuma/Theme
cd app/code/ReactLuma/Theme
git clone .

Enable CSS critical path

bin/magento config:set dev/css/use_css_critical_path 1
php bin/magento config:set dev/js/move_script_to_bottom 1




True Stories about Magento 2. Melting metal server infrastructure into cloud solutions. Donate:

Love podcasts or audiobooks? Learn on the go with our new app.

How we made the entire company* cross-functional**

Reactive selfies with Camera2 API on Android — Part 2

ShoppieBuzz- E-commerce Website builder

Serverless Blue-Green Deployment

[ELI5] Docker: Basics

Docker Explain Like I’m 5

Flask Upload Image Directly to s3 without saving in server

Advanced Positioning In CSS

Frantic Research: Week 1 of My Software Engineering Challenge

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yegor Shytikov

Yegor Shytikov

True Stories about Magento 2. Melting metal server infrastructure into cloud solutions. Donate:

More from Medium

Calculate PHP cache time with ease

Symfony Station Communique — 3 December 2021. A Look at Symfony and PHP News.

The love story between Symfony and HTTP

PHP 7.4 vs PHP 8.1 Magento 2 an Adobe Commerce Performance