Advanced on-premises installation
Command-line interface (CLI)
Adobe Commerce and Magento Open Source have a single command-line interface for installation and configuration tasks: <magento_root>/bin/magento
. The interface performs multiple tasks, including:
- Installation (and related tasks such as creating or updating the database schema, creating the deployment configuration).
- 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 installing the Adobe Commerce or Magento Open Source software using the CLI. For information about configuration, see the Configuration Guide.
The installer can 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 Adobe Commerce or Magento Open Source in a different database instance
Before you start your installation
Before you begin, complete the following steps:
-
Verify that your system meets the requirements discussed in system requirements.
-
Complete all prerequisite tasks.
-
Complete the first installation steps. See your install or upgrade path.
-
After you log in to the application server, switch to the file system owner.
-
Review the installation quick start overview.
bin
subdirectory.You can run the installer multiple times with different options to complete installation tasks like the following:
-
Install in phases — For example, after you configure your web server for Secure Sockets Layer (SSL), you can run the installer again to set SSL options.
-
Correct mistakes in previous installations.
-
Install Adobe Commerce or Magento Open Source in a different database instance.
cleanup-database
parameter to change this behavior.See also Update, reinstall, uninstall.
Secure installation
To use Secure Sockets Layer (SSL), also referred to as HTTPS, for both the Admin and the storefront, you must set all of the following parameters:
--use-secure
: Set to1
--base-url-secure
: Set to a secure URL (that is, starting withhttps://
)--use-secure-admin
Set to1
More details about these parameters can be found later in this topic.
Installer help commands
You can run the following commands to find values for some required arguments:
Install from the command line
The install command uses the following format:
bin/magento setup:install --<option>=<value> ... --<option>=<value>
The following tables describe the installation option names and values. For example installation commands, see Sample localhost installations.
Admin credentials:
The following options specify the user information and credentials for the Admin user.
You can create the Admin user during or after installation. If you create the user during installation, all admin credential variables are required. See Sample localhost installations.
The following tables provide many but not all available install parameters. For a complete list, see the Command-line Tools Reference.
--admin-firstname
--admin-lastname
--admin-email
--admin-user
--admin-password
--admin-password='A0b9%t3g'
Site and database configuration options:
--base-url
http[s]://<host or ip>/<your install dir>/
.Note: The scheme (http:// or https://) and a trailing slash are both required.
<your install dir>
is the docroot-relative path in which to install the Adobe Commerce or Magento Open Source software. Depending on how you set up your web server and virtual hosts, the path might be magento2 or it might be blank.To access Adobe Commerce or Magento Open Source on localhost, you can use either
http://127.0.0.1/<your install dir>/
or http://127.0.0.1/<your install dir>/
.-
{{base_url}}
which represents a base URL defined by a virtual host setting or by a virtualization environment like Docker. For example, if you set up a virtual host with the hostname magento.example.com
, you can install the software with --base-url={{base_url}}
and access the Admin with a URL like http://magento.example.com/admin
.--backend-frontname
admin_jkhgdfq
.We recommend a random URI for security purposes. A random URI is harder for hackers or malicious software to exploit.
The URI displays at the end of the installation. You can display it later at any time using the
bin/magento info:adminuri
command.If you choose to enter a value, we recommend you not use a common word like admin, backend. The Admin URI can contain alphanumeric values and the underscore character (
_
) only.--db-host
- The database server’s fully qualified hostname or IP address.
-
localhost
(default) or 127.0.0.1
if your database server is on the same host as your web server.localhost means the MySQL client library uses UNIX sockets to connect to the database. 127.0.0.1
causes the client library to use the TCP protocol. For more information about sockets, see the PHP PDO_MYSQL documentation.Note: You can optionally specify the database server port in its hostname like www.example.com:9000
--db-name
Default is
magento2
.--db-user
Default is
root
.--db-password
--db-prefix
In that case, use a prefix to identify the tables for this installation. Some customers have more than one Adobe Commerce or Magento Open Source instance running on a server with all tables in the same database.
The prefix can be a maximum of five characters in length. It must begin with a letter and can include only letters, numbers, and underscore characters.
This option enables those customers to share the database server with more than one Adobe Commerce or Magento Open Source installation.
--db-ssl-key
--db-ssl-cert
--db-ssl-ca
--language
bin/magento info:language:list
from the bin directory.)--currency
bin/magento info:currency:list
from the bin directory.)--timezone
bin/magento info:timezone:list
from the bin/
directory.)--use-rewrites
1
means you use web server rewrites for generated links in the storefront and Admin.0
disables the use of web server rewrites. This is the default.--use-secure
1
enables the use of Secure Sockets Layer (SSL) in storefront URLs. Make sure that your web server supports SSL before you select this option.0
disables the use of SSL. In this case, all other secure URL options are assumed to also be 0. This is the default.--base-url-secure
http[s]://<host or ip>/<your install dir>/
--use-secure-admin
1
means you use SSL to access the Admin. Make sure that your web server supports SSL before you select this option.0
means you do not use SSL with the Admin. This is the default.--admin-use-security-key
0
disables the use of the key.--session-save
-
db
to store session data in the database. Choose database storage if you have a clustered database; otherwise, there might not be much benefit over file-based storage.-
files
to store session data in the file system. File-based session storage is appropriate unless the file system access is slow, you have a clustered database, or you want to store session data in Redis.-
redis
to store session data in Redis. If you are using Redis for default or page caching, Redis must be already installed. See Use Redis for session storage for additional information about configuring support for Redis.--key
--cleanup-database
--db-init-statements
Default is
SET NAMES utf8;
.--sales-order-increment-prefix
Search engine configuration options:
--search-engine
elasticsearch7
. Elasticsearch 5 has been deprecated and is not recommended.--elasticsearch-host
localhost
.--elasticsearch-port
9200
.--elasticsearch-index-prefix
magento2
.--elasticsearch-timeout
15
.--elasticsearch-enable-auth
false
.--elasticsearch-username
--elasticsearch-password
--opensearch-host
localhost
.--opensearch-port
9200
.--opensearch-index-prefix
magento2
.--opensearch-timeout
15
.--opensearch-enable-auth
false
.--opensearch-username
--opensearch-password
RabbitMQ configuration options:
--amqp-host
--amqp
options unless you have already set up an installation of RabbitMQ. See RabbitMQ installation for more information about installing and configuring RabbitMQ.The hostname where RabbitMQ is installed.
--amqp-port
--amqp-user
guest
.--amqp-password
guest
.--amqp-virtualhost
/
.--amqp-ssl
false
. See RabbitMQ for information about setting up SSL for RabbitMQ.--consumers-wait-for-messages
Lock configuration options:
--lock-provider
Available lock providers:
db
, zookeeper
, file
.The default lock provider:
db
--lock-db-prefix
db
lock provider.The default value:
NULL
--lock-zookeeper-host
zookeeper
lock provider.For example:
127.0.0.1:2181
--lock-provider=zookeeper
--lock-zookeeper-path
The default path is:
/magento/locks
--lock-file-path
--lock-provider=file
Consumers configuration options:
--consumers-wait-for-messages
-
0
: Consumers process available messages in the queue, close the TCP connection, and terminate. Consumers do not wait for additional messages to enter the queue, even if the number of processed messages is less than the--max_messages
value specified during starting consumers. -
1
: Consumers continue to process messages from the message queue until reaching the maximum number of messages (the value specified for--max_messages
on thequeue:consumers:start
command) before closing the TCP connection and terminating the consumer process. If the queue empties before reaching--max_messages
the consumer waits for more messages to arrive. If you use workers to run consumers instead of using a cron job, set this variable to1
.
--consumers-wait-for-messages
option is a global option and cannot be configured separately for each consumer.Sensitive data:
Adobe Commerce and Magento Open Source use your encryption key to encrypt the following:
- Credit card information
- Usernames and passwords specified in the Admin configuration (for example, logins to payment gateways)
- CAPTCHA values sent over the network
Adobe Commerce and Magento Open Source do not encrypt:
- Administrative and customer usernames and passwords (these passwords are hashed)
- Address
- Phone number
- Other types of personally identifiable information except for credit card numbers
Sample localhost installations
The following examples show the commands to install Adobe Commerce locally with various options.
Example 1—Basic installation with admin user account
The following example installs Adobe Commerce or Magento Open Source with the following options:
-
The application is installed in the
magento2
directory relative to the web server docroot onlocalhost
and the path to the Admin isadmin
; therefore:Your storefront URL is
http://127.0.0.1
-
The database server is on the same host as the web server.
The database name is
magento
, and the username and password are bothmagento
-
Uses server rewrites
-
The administrator has the following properties:
- First and last names are
Magento User
- Username is
admin
and the password isadmin123
- E-mail address is
user@example.com
- First and last names are
-
Default language is
en_US
(U.S. English) -
Default currency is U.S. dollars
-
Default time zone is U.S. Central (America/Chicago)
-
OpenSearch 1.2 is installed on
os-host.example.com
and connects on port 9200
magento setup:install --base-url=http://127.0.0.1/magento2/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1 \
--search-engine=opensearch --opensearch-host=os-host.example.com \
--opensearch-port=9200
Messages similar to the following display to indicate a successful installation:
Post installation file permissions check...
For security, remove write permissions from these directories: '/var/www/html/magento2/app/etc'
[Progress: 274 / 274]
[SUCCESS]: Magento installation complete.
[SUCCESS]: Admin Panel URI: /admin_puu71q
Example 2— Basic install without admin user account
You can install Adobe Commerce or Magento Open Source without creating the administrator user as shown in the following example.
magento setup:install --base-url=http://127.0.0.1/magento2/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 \
--search-engine=opensearch --opensearch-host=os-host.example.com \
--opensearch-port=9200
Messages like the following display if the installation is successful:
Post installation file permissions check...
For security, remove write permissions from these directories: '/var/www/html/magento2/app/etc'
[Progress: 274 / 274]
[SUCCESS]: Magento installation complete.
[SUCCESS]: Admin Panel URI: /admin_puu71q
After installation you can create an admin user using the admin:user:create
command:
Create or edit an administrator
Example 3—Install with additional options
The following example installs Adobe Commerce or Magento Open Source with the following options:
-
The application is installed in the
magento2
directory relative to the web server docroot onlocalhost
and the path to the Admin isadmin
; therefore:Your storefront URL is
http://127.0.0.1
-
The database server is on the same host as the web server.
The database name is
magento
, and the username and password are bothmagento
-
The administrator has the following properties:
- First and last names are
Magento User
- Username is
admin
and the password isadmin123
- E-mail address is
user@example.com
- First and last names are
-
Default language is
en_US
(U.S. English) -
Default currency is U.S. dollars
-
Default time zone is U.S. Central (America/Chicago)
-
The installer first cleans up the database before installing the tables and schema
-
You can use the sales order increment prefix
ORD$
(since it contains a special character [$
], the value must be enclosed in double quotes) -
Session data is saved in the database
-
Uses server rewrites
-
OpenSearch is installed on
os-host.example.com
and connects on port 9200
magento setup:install --base-url=http://127.0.0.1/magento2/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --cleanup-database \
--sales-order-increment-prefix="ORD$" --session-save=db --use-rewrites=1 \
--search-engine=opensearch --opensearch-host=os-host.example.com \
--opensearch-port=9200
\
character at the end of each line.Messages like the following display if the installation is successful:
Post installation file permissions check...
For security, remove write permissions from these directories: '/var/www/html/magento2/app/etc'
[Progress: 274 / 274]
[SUCCESS]: Magento installation complete.
[SUCCESS]: Admin Panel URI: /admin_puu71q