1

I'm running a Magento Commerce Cloud in my new machine and I need to install the Magento Cloud CLI.

How could I do it?

2 Answers 2

3

1 - You can install it using this command below.

curl -sS https://accounts.magento.cloud/cli/installer | php

2 - Then add the Magento Cloud CLI to the bash profile.

export PATH=$PATH:$HOME/.magento-cloud/bin

3 - And reload the bash.

. ~/.bash_profile

4- To check if it worked run:

magento-cloud

Reference: Magento Cloud CLI reference

3
  • i am getting following error when run first command "Invoke-WebRequest : A parameter cannot be found that matches parameter name 'sS'. At line:1 char:6 + curl -sS accounts.magento.cloud/cli/installer | php + ~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
    – Alam Zaib
    May 6, 2021 at 7:55
  • Check your local PHP, I just test it and it's working normally @AlamZaib May 6, 2021 at 17:43
  • I have xampp server having php 7.4
    – Alam Zaib
    May 9, 2021 at 7:06
0

To Install the magento-cloud CLI

Step-1 : Go to /var/www/html folder and create new folder magentocloud. After go into magentocloud folder.

  cd /var/www/html/

  mkdir magentocloud

  cd magentocloud/

Step-2 : Install the magento-cloud CLI.

  curl -sS https://accounts.magento.cloud/cli/installer | php

OUTPUT:

  username@linux-pc:/var/www/html/magentocloud$ curl -sS https://accounts.magento.cloud/cli/installer | php
  Magento Cloud CLI installer

  Environment check
    [*] The "json" PHP extension is installed.
    [*] The "phar" PHP extension is installed.
    [*] Git is installed.
    [*] The "openssl" PHP extension is installed.
    [*] The "pcre" PHP extension is installed.
    [*] One or both of the "mbstring" or "iconv" PHP extensions is installed.
    [*] The "curl" PHP extension is installed.
    [*] The "pcntl" and "posix" extensions are installed.
    [*] The "allow_url_fopen" setting is on.
    [*] The "apc.enable_cli" setting is off.

  Download
    Finding the latest version... done
    Downloading version 1.38.1... done
    Checking file integrity... done
    Checking that the file is a valid Phar... done

  Install
    Making the Phar executable... done
    Moving the Phar to your home directory... done
    Executable location: /home/username/.magento-cloud/bin/magento-cloud

  Running self:install command...

  Copying resource files... done

  Installing credential helper... done

  Setting up autocompletion... done

  Selected shell configuration file: ~/.bashrc

  Do you want to update the file automatically? [Y/n] y

  Configuration file updated successfully: ~/.bashrc

  To use the Magento Cloud CLI, run:
      source ~/.bashrc # (make sure your shell does this by default)
      magento-cloud

Step-3 : Add magento-cloud CLI to the bash profile

  export PATH=$PATH:$HOME/.magento-cloud/bin

Step-4 : Reload the updated bash profile.

  . ~/.bash_profile

After running the Step-2 command we get the profile name. Used that name.

  . ~/.bashrc

Step-5 : To initiate the CLI, call magento-cloud and enter your Cloud account credentials when prompted.

  magento-cloud

OutPut:

  username@linux-pc:/var/www/html/magentocloud$ magento-cloud
  Welcome to Magento Cloud!

  Loading projects...
  Authentication is required.

  Log in via a browser? [Y/n] y

  Opened URL: http://127.0.0.1:5000
  Please use the browser to log in.

  Help:
    Leave this command running during login.
    If you need to quit, use Ctrl+C.

  Opening in existing browser session.
  libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
  Login information received. Verifying...
  You are logged in.

  Generating SSH certificate...
  A new SSH certificate has been generated.
  It will be automatically refreshed when necessary.
  Do you want to create an SSH configuration file automatically? [Y/n] y
  Configuration file created successfully: /home/username/.ssh/config

  Username: cloud-username cloud-username
  Email address: [email protected]
  Your projects are:
  +---------------+------------------+-----------------------------------------------------+
  | ID            | Title            | URL                                                 |
  +---------------+------------------+-----------------------------------------------------+
  | XXXXXXXXXXXXX | Project Name 1   | https://XXXXXX.magento.cloud/projects/XXXXXXXXXXXXX |
  | XXXXXXXXXXXXX | Project Name 2   | https://XXXXXX.magento.cloud/projects/XXXXXXXXXXXXX |
  +---------------+------------------+-----------------------------------------------------+

  Get a project by running: magento-cloud get [id]
  List a project's environments by running: magento-cloud environments -p [id]

  You are logged in as cloud-username (cloud.usern[email protected])

  To view all commands, run: magento-cloud list

enter image description here

You must be login into browser with magento-cloud account.

Step-6 : Verify the magento-cloud command is in your path. The following example lists the available commands.

  magento-cloud list

OutPUT:

username@linux-pc:/var/www/html/magentocloud$ magento-cloud list
Magento Cloud CLI 1.38.1

Global options:
  --help           -h Display this help message
  --quiet          -q Do not output any message
  --verbose        -v|vv|vvv Increase the verbosity of messages
  --version        -V Display this application version
  --yes            -y Answer "yes" to any yes/no questions; disable interaction
  --no             -n Answer "no" to any yes/no questions; disable interaction

Available commands:
  clear-cache (clearcache, cc)                                  Clear the CLI cache
  decode                                                        Decode an encoded string such as MAGENTO_CLOUD_VARIABLES
  docs                                                          Open the online documentation
  help                                                          Displays help for a command
  list                                                          Lists commands
  multi                                                         Execute a command on multiple projects
  web                                                           Open the Web UI
activity
  activity:cancel                                               Cancel an activity
  activity:get                                                  View detailed information on a single activity
  activity:list (activities, act)                               Get a list of activities for an environment or project
  activity:log                                                  Display the log for an activity
app
  app:config-get                                                View the configuration of an app
  app:list (apps)                                               List apps in the project
auth
  auth:api-token-login                                          Log in to Magento Cloud using an API token
  auth:browser-login (login)                                    Log in to Magento Cloud via a browser
  auth:info                                                     Display your account information
  auth:logout (logout)                                          Log out of Magento Cloud
backup
blackfire
  blackfire:setup                                               Setup Blackfire.io integration for the project
certificate
  certificate:add                                               Add an SSL certificate to the project
  certificate:delete                                            Delete a certificate from the project
  certificate:get                                               View a certificate
  certificate:list (certificates, certs)                        List project certificates
commit
  commit:get                                                    Show commit details
  commit:list (commits)                                         List commits
db
  db:dump                                                       Create a local dump of the remote database
  db:size                                                       Estimate the disk usage of a database
  db:sql (sql)                                                  Run SQL on the remote database
domain
  domain:add                                                    Add a new domain to the project
  domain:delete                                                 Delete a domain from the project
  domain:get                                                    Show detailed information for a domain
  domain:list (domains)                                         Get a list of all domains
  domain:update                                                 Update a domain
environment
  environment:activate                                          Activate an environment
  environment:branch (branch)                                   Branch an environment
  environment:checkout (checkout)                               Check out an environment
  environment:delete (environment:deactivate)                   Delete an environment
  environment:http-access (httpaccess)                          Update HTTP access settings for an environment
  environment:info                                              Read or set properties for an environment
  environment:init                                              Initialize an environment from a public Git repository
  environment:list (environments, env)                          Get a list of environments
  environment:logs (log)                                        Read an environment's logs
  environment:merge (merge)                                     Merge an environment
  environment:push (push)                                       Push code to an environment
  environment:redeploy (redeploy)                               Redeploy an environment
  environment:relationships (relationships)                     Show an environment's relationships
  environment:scp (scp)                                         Copy files to and from current environment using scp
  environment:ssh (ssh)                                         SSH to the current environment
  environment:synchronize (sync)                                Synchronize an environment's code and/or data from its parent
  environment:url (url)                                         Get the public URLs of an environment
  environment:xdebug (xdebug)                                   Open a tunnel to Xdebug on the environment
i
integration
  integration:activity:get                                      View detailed information on a single integration activity
  integration:activity:list (i:act)                             Get a list of activities for an integration
  integration:activity:log                                      Display the log for an integration activity
  integration:add                                               Add an integration to the project
  integration:delete                                            Delete an integration from a project
  integration:get                                               View details of an integration
  integration:list (integrations)                               View a list of project integration(s)
  integration:update                                            Update an integration
  integration:validate                                          Validate an existing integration
local
  local:build (build)                                           Build the current project locally
  local:dir (dir)                                               Find the local project root
mount
  mount:download                                                Download files from a mount, using rsync
  mount:list (mounts)                                           Get a list of mounts
  mount:size                                                    Check the disk usage of mounts
  mount:upload                                                  Upload files to a mount, using rsync
project
  project:clear-build-cache                                     Clear a project's build cache
  project:get (get)                                             Clone a project locally
  project:info                                                  Read or set properties for a project
  project:list (projects, pro)                                  Get a list of all active projects
  project:set-remote                                            Set the remote project for the current Git repository
repo
  repo:cat                                                      Read a file in the project repository
  repo:ls                                                       List files in the project repository
route
  route:get                                                     View detailed information about a route
  route:list (routes)                                           List all routes for an environment
self
  self:install                                                  Install or update CLI configuration files
  self:update (self-update)                                     Update the CLI to the latest version
service
  service:list (services)                                       List services in the project
  service:mongo:dump (mongodump)                                Create a binary archive dump of data from MongoDB
  service:mongo:export (mongoexport)                            Export data from MongoDB
  service:mongo:restore (mongorestore)                          Restore a binary archive dump of data into MongoDB
  service:mongo:shell (mongo)                                   Use the MongoDB shell
  service:redis-cli (redis)                                     Access the Redis CLI
snapshot
  snapshot:create (backup)                                      Make a snapshot of an environment
  snapshot:list (snapshots)                                     List available snapshots of an environment
ssh-cert
  ssh-cert:load                                                 Generate an SSH certificate
ssh-key
  ssh-key:add                                                   Add a new SSH key
  ssh-key:delete                                                Delete an SSH key
  ssh-key:list (ssh-keys)                                       Get a list of SSH keys in your account
tunnel
  tunnel:close                                                  Close SSH tunnels
  tunnel:info                                                   View relationship info for SSH tunnels
  tunnel:list (tunnels)                                         List SSH tunnels
  tunnel:open                                                   Open SSH tunnels to an app's relationships
  tunnel:single                                                 Open a single SSH tunnel to an app relationship
user
  user:add                                                      Add a user to the project
  user:delete                                                   Delete a user from the project
  user:get                                                      View a user's role(s)
  user:list (users)                                             List project users
  user:update                                                   Update user role(s) on a project
variable
  variable:create                                               Create a variable
  variable:delete                                               Delete a variable
  variable:get (vget)                                           View a variable
  variable:list (variables, var)                                List variables
  variable:update                                               Update a variable
worker
  worker:list (workers)                                         Get a list of all deployed workers

Reference Link : https://devdocs.magento.com/cloud/reference/cli-ref-topic.html

Note: Create your local machine SSH key and add into your magento cloud account. Before you start installing Magento Cloud CLI you must be login into browser with your cloud account

ssh-keygen -t ed25519 -a 100 -C "[email protected]"

Add SSH key Here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.