Get started with the command-line installation

Before you start your installation

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.

The installer is designed to be run multiple times if necessary so you can:

  • Provide different values

    For example, after you configure your web server for Secure Sockets Layer (SSL), you can run the installer to set SSL options.

  • Correct mistakes in previous installations
  • Install Magento in a different database instance

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?

In addition to the command arguments discussed here, see Common arguments.

Command summary

The following table summarizes the available commands. Commands are shown in summary form only; for more information about a command, click the link in the Command column.

Command Description Prerequisites
magento setup:install Installs the Magento software None
magento setup:uninstall Removes the Magento software. Magento software installed
magento setup:upgrade Updates the Magento software. Deployment configuration
magento maintenance:{enable/disable} Enables or disables maintenance mode (in maintenance mode, only exempt IP addresses can access the Magento Admin or storefront). Magento software installed
magento setup:config:set Creates or updates the deployment configuration. None
magento module:{enable/disable} Enable or disable modules. None
magento setup:store-config:set Sets storefront-related options, such as base URL, language, timezone, and so on. Deployment configuration
Database (simplest way is to use magento setup:upgrade)    
magento setup:db-schema:upgrade Updates the Magento database schema. Deployment configuration
magento setup:db-data:upgrade Updates the Magento database data. Deployment configuration
magento setup:db:status Checks if the database is up-to-date with the code. Deployment configuration
magento admin:user:create Creates a Magento administrator. All of the following:

Deployment configuration

Enable at minimum the Magento_User and Magento_Authorization modules

Database (simplest way is to use magento setup:upgrade)
magento list Lists all available commands. None
magento help Provides help for the specified command. None

Help commands

To display a complete list of commands, enter:

1
magento list

To get help for a particular command, enter:

1
magento help <command>

For example,

1
magento help setup:install
1
magento help cache:enable

Common arguments

The following arguments are common to all commands. These commands can be run either before or after the Magento software is installed:

Long version Short version Meaning
--help -h Get help for any command. For example, ./magento help setup:install or ./magento help setup:config:set.
--quiet -q Quiet mode; no output.
--no-interaction -n No interactive questions.
--verbose=1,2,3 -v, -vv, -vvv Verbosity level. For example, --verbose=3 or -vvv displays debug verbosity, which is the most verbose output. Default is --verbose=1 or -v.
--version -V Display this application version
--ansi n/a Force ANSI output
--no-ansi n/a Disable ANSI output