Command line configuration

Introducing the Magento command-line interface (CLI)

Magento has one command-line interface that performs both installation and configuration tasks: <magento_root>/bin/magento. The new interface performs multiple tasks, including:

  • Installing Magento (and related tasks such as creating or updating the database schema, creating the deployment configuration, and so on).
  • Clearing the cache.
  • Managing indexes, including reindexing.
  • Creating translation dictionaries and translation packages.
  • Generating non-existent classes such as factories and interceptors for plug-ins, generating the dependency injection configuration for the object manager.
  • Deploying static view files.
  • Creating CSS from Less.

Other benefits:

  • A single command (<magento_root>/bin/magento list) lists all available installation and configuration commands.
  • Consistent user interface based on Symfony.
  • The CLI is extensible so third party developers can “plug in” to it. This has the additional benefit of eliminating users’ learning curve.
  • Commands for disabled modules do not display.

This topic discusses configuring the Magento software using the CLI. For information about installing Magento, see Installation overview.

Before you start configuring Magento

Before you begin, make sure that:

  1. Your system meets the requirements discussed in Magento System Requirements
  2. You completed all prerequisite tasks discussed in Prerequisites.
  3. After you log in to the Magento server, switch to a user that has permissions to write to the Magento file system. One way to do this is discussed in switch to the Magento file system owner.

First steps

  1. Log in to the Magento server as, or switch to, a user with permissions to write to the Magento file system. See switch to the Magento file system owner.

    If you use the bash shell, you can use the following syntax to switch to the Magento file system owner and enter the command at the same time:

    1
    
    su <Magento file system owner> -s /bin/bash -c <command>
    

    If the Magento file system owner does not allow logins, you can do the following:

    1
    
    sudo -u <Magento file system owner>  <command>
    
  2. To run Magento commands from any directory, add <magento_root>/bin to your system PATH.

    Because shells have differing syntax, consult a reference like unix.stackexchange.com.

    Sample bash shell for CentOS:

    1
    
    export PATH=$PATH:/var/www/html/magento2/bin
    

    Optionally, you can run the commands in the following ways:

    • cd <magento_root>/bin and run them as ./magento <command name>
    • <magento_root>/bin/magento <command name>
    • <magento_root> is a subdirectory of your web server docroot. Need help locating the docroot?

Related topics

Get started with command-line configuration