Command line configuration

Introducing the Magento command-line interface (CLI)

Magento has one command-line interface that performs both installation and configuration tasks: <your Magento install dir>/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 (php <your Magento install dir>/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 who has permissions to write to the Magento file system. One way to do this is to switch to the Magento file system owner.

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

    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
    
    sudo -u <Magento file system owner>  <command>
    
  2. To run Magento commands from any directory, add <your Magento install dir>/bin to your system PATH.

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

    bash shell example for CentOS:

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

You can also run the commands in the following ways:

  • cd <your Magento install dir>/bin and run them as ./magento <command name>
  • php <your Magento install dir>/bin/magento <command name>

<your Magento install dir> is a subdirectory of your web server's docroot. Need help locating the docroot? Click here.

Next step

Get started with command-line configuration