Magento Cloud - How to Setup Local Environment?

Magento Cloud - How to Setup Local Environment?

Magento 2 is a leading eCommerce Platform, available for enterprise and community as well.

Magento Commerce (Cloud) was formerly known as Magento Enterprise Cloud Edition which was introduced in early 2016 as Magento’s third platform option, alongside Magento Commerce and Magento OpenSource. 

Magento 2 Cloud offers services as a platform based on Amazon Web Services (AWS) global infrastructure. To access Magento Cloud and work on your store, you should have a Magento Commerce (Cloud) Account. This account provides access to all projects for developing and deploying them across all supported environments.

All environments for a project are read-only. If we work on any environment, it requires work to be done at local environment first and pushed to cloud environment. To start working and developing on Magento, you need:


  1. A configured local workspace,
  2. Cloned Magento Commerce Cloud Code from your Git branch


Here, in this article, you will see the instructions which will help you to create a local workspace for development on your local system.

If you are a Magento Developer, then you will need an access to Magento Cloud Project. For that, Project Owner ( will invite you to access the project in your company’s or individual Magento Commerce Cloud Account for connecting it to local. It will give you the access to all source code and deployment environments.

Now, to work on a project, you will receive an email invitation to verify and access the project. Click the Verify my Account option in the email. When you log on to your account and have access to multiple projects then you will see the list of all projects. Select the specific project and it will open with a master branch to work with.


Install Magento Prerequisites:

We assume that you are having LINUX/MAC based host computer. For Magento development, following software packages and tools should be installed:


Virtual machine or container (host):

It is recommended (but optional) to install VM for developing and managing your host. Following packages can be used for VM:


  1. Vagrant ( for a virtual machine
  2. Docker ( for a container


Development Tools


  1. GIT ( – provides code branching and management for accessing Magento Commerce and code repositories. For more information, see How Cloud uses Git (
  2. Composer: It is used for dependency management and enables developer to manage the Magento components and their dependencies. For more information, see How Cloud uses Composer (


Web Server:

Nginx ( is strongly recommended though Magento Commerce Cloud supports Apache ( too.


PHP (local):
Install PHP on your local machine and PHP 7.0 is recommended.

Set up PHP Memory Limit:
To set memory_limit, open php.ini in a text editor and set the value to at least 1G and 2G for debugging. Then restart the web server – service apache2 restart for Apache and service nginx restart for Nginx


Database (Local):
There are following options for database:


  1. MariaDB (recommended) (
  2. MYSQL


Magento Cloud CLI (local)

The Magento Cloud command-line interface (CLI) tool helps to manage projects and code branches on Magento Commerce Cloud. You can check the list of CLI commands here( ). 


  1. Following are the steps to install Magento Cloud CLI in LINUX/MAC:
  2. Open a terminal with root privileges.
  3. Create a Magento File Owner by following these steps:
    1. sudo adduser magento_user
    2. It will ask for password. Enter desired password
    3. Now, it will ask for user information for magento_user – Full Name, Room Number, Work Phone, Home Phone, Others.
    4. Assign user to www-data group: usermod -g www-data magento_user
    5. Assign user to root group: usermod -g root magento_user
    6. Restart Apache: service apache2 restart
  4. Switch to magento_user: su magento_user
  5. Change to a directory to which the Magento file system owner has write access, such as the home directory. cd /home/magento_user/
  6. Install the Magento Cloud CLI:
    1. Run:
      curl -sS | php
      It will install Magento Cloud CLI.
    2. To use the Magento Cloud CLI, run: source /home/magento_user/.bashrc
    3. You can also add the following path into Magento user’s path”
      export PATH=$PATH:/home/magento_user/.magento-cloud/bin
    4. To check if it has been installed, run
      magento-cloud list and you will see the list of commands. Following is the screenshot:



The SSH Protocol ( is designed to maintain a secure connection between two systems - in this case, local working environment and Magento Commerce Cloud Git project.

An SSH key pair should be created on local work machine to work with and access Magento Commerce Cloud and GitHub Branches. The SHH Keys supports to connect to GitHub for managing branches and pushing the code.


Following are the steps to create SSH Keys:


  1. Open a terminal and log in as Magento File Owner.
  2. Run this command - ssh-keygen -t rsa -b 4096 -C "[email protected]". Here, email id should belong to GitHub Account.
  3. Enter a file in which to save the key (/home/magento_user/.ssh/magento_user_rsa): [Press enter]
  4. Enter passphrase (empty for no passphrase): [Type a passphrase]
  5. Enter same passphrase again: [Type passphrase again]
  6. Run: eval "$(ssh-agent -s)"
  7. Run: ssh-add  /home/magento_user/.ssh/magento_user_rsa


Following are the steps to add a public SSH key into your Magento Commerce Cloud Account:


  1.  Open a terminal application on your local.
  2.  Log in with Magento File Owner and go to its home directory.
  3.  To log on to Magento Clound Account, run -
    magento-cloud auth:password-login
    It will ask for login. Enter username and password of your Magento Commerce Cloud Account. Or run the following command to login through browser:
     magento-cloud auth:browser-login
    It will redirect you to browser for loggin in. If it does not find protocol and shows error then it will suggest you to open a localhost URL manually. For instance – When you open this URL, it will show you the following:
    It will be logged in and following will be displayed:


  1. Now, to add the ky, run:
    magento-cloud ssh-key:add /home/magento_user/.ssh/magento_user_rsa
    It will ask to enter the name of the key. Enter the key name. For instance -


  1. Run: git config --global "<Your name>"
  2. Run: git config --global <Your GitHub Account email id>


Following are the steps to add your SSH keys into your GitHub account: 


    1. Open a new terminal with root privilege. Copy the SSH key to your clipboard by running the following commands:


    1. sudo apt-get install xclip
    2. xclip -sel clip < /home/magento_user/.ssh/
  1. Now, go to and log on to your Account.
  2. Go to Settings
  3. Create a New SSH Key
  4. Enter Title and paste Key into Key field.
  5. Click ADD SSH KEY button.
  6. It will ask you to re-enter the Git Password to verify it’s you.


After adding the SSH keys, test the SSH connection to GitHub by running the following command:

  1. ssh -T [email protected]

    < It will show you successful message if everything is fine. If it shows any error or Permission Denied issue, click here( to check the solution. Following is the screenshot.



Following are the steps to clone a branch (master) of a project:


Run: magento-cloud login
Run: magento-cloud project:list
Run: magento-cloud project:get <project ID>
Run: magento-cloud environment:list
Run: git fetch magento
Run: git pull magento <environment ID>
Run: cd <dirname>
Run: magento-cloud build