How to Set up Magento 2 Cloud Local Setup?

The Magento is the leading platform as it provides services for both - Community as well as enterprise. Magento commerce is Magento Enterprise Cloud Edition. Magento 2 cloud helps you with services that are platform-based on AWS (Amazon Web Services). You must have Magento Cloud/Commerce Account to access Magento Cloud services.

So, today we'll see how to set up Magento 2 cloud local setup. We need to work on the local environment first as all environments for projects are read-only. Then after they are pushed to the cloud environment. Here we'll see the way how to set up Magento 2 Cloud local setup.

What do you need to Set up Magento 2 Cloud local setup?

 

1.  Local Work Space &

2. Cloned Magento Commerce Cloud Code from Git Branch

Cloned Magento Commerce Cloud Code from Git Branch

 ⇒ For development work, you need to access Magento Cloud Project. The project owner gives you access to the company's or individual Magento Commerce Cloud Account to connect to local. That will allow you to all source code and deployment environments.

⇒ Once you receive an email, then verify it. After verification, you can select your project to work on. And that will open the master branch to work.

⇒ Magento Installation Essentials:

Magento Installation Essentials

→ Following software packages are required: (We assume that you are running LINUX/MAC-based host)

Virtual Machine / Container:  Vagrant for VM & Docker for Container

→  Development Tools: Git & Composer

Web Server: Nginx/Apache

PHP: PHP 7.0 is preferable in your local and set up a memory limit from php.ini at least 1G to 2G for debugging. (Need to restart the webserver services also)

Database: MariaDB/MYSQL (Local)

⇒ Magento Cloud CLI (local)

Magento Cloud CLI (local)

→ You can manage projects and code branches on Magento Commerce Cloud using Command Line Interface.

→ Steps to install Magento Cloud CLI in LINUX/MAC:

– Open a command line with root privileges

– Create Magento File Owner:

• sudo adduser m_user

• Password to create

• Fill in required users details

• Assign a www-data group to the user: usermod -g www-data m_user

• Assign root group also to the user: usermod -g root m_user

• Restart server

– Switch to m_user: su m_user

– Change to the directory which has write access: cd /home/m_user/

⇒ Install Magento Cloud CLI:

→ Run: curl -sS <Installer> | php // It installs Magento Cloud CLI

→ To use: source /home/m_user/.bashrc

→ Add Path: export PATH=$PATH:/home/m_user/.magento-cloud/bin

→ To check installation: Run magento-cloud list and check commands list.

  1. Run:
    curl -sS https://accounts.magento.cloud/cli/installer | php
    It will install Magento Cloud CLI.

⇒ Enable SSH

→ To secure connection, SSH protocol needs to enable.

→ SSH key pair is required to create on a local machine to access Magento Commerce Cloud and GitHub Branches.

Steps to enable SSH:

– Open the Command line and log in as File owner

– Run: - ssh-keygen -t rsa -b 4096 -C "Your Email" (Write email id that belongs to GitHub)

– Enter file that will contain key (/home/m_user/.ssh/m_user_rsa) ↵

– Enter passphrase

– Run: eval "$(ssh-agent -s)"

– Run: ssh-add  /home/m_user/.ssh/m_user_rsa

⇒ Add Public SSH Key to Magento Commerce Cloud

→ Open command line

→ Log in as File Owner

→ Go to Home directory

→ Run to log in to Magento Cloud Account: magento-cloud auth:password-login

→ Enter correct username and password. (Else you can log in through browser also)

→ Set up a key:

– Run: magento-cloud ssh-key:add /home/m_user/.ssh/m_user_rsa

– Enter Key name

→ Git Configuration:

– git config --global user.name "<Your name>"

– git config --global user.email <Your GitHub Account email id>

⇒ Add SSH to GitHub Account:

→ Open command line with root

→ Run: sudo apt-get install xclip // Copy SSH

→ xclip -sel clip < /home/m_user/.ssh/id_rsa.pub

→ Log in to your GitHub Account → Settings → SSH key → Enter title & Paste key → Add SSH key button

→ Renter Password and finish verification.

⇒ Clone Project Master

→ Run: magento-cloud login

magento-cloud project:list

magento-cloud project:get <project id>

magento-cloud environment:list

git fetch magento

git pull magento <environment id>

cd <dir_name>

magento-cloud build

Subscribe with your email id to get more solutions for your queries.

Take good care! :)