Install Magento using Composer

We use Composer to manage Magento components and their dependencies. Using Composer to get the Magento software metapackage provides the following advantages:

  • Reuse third-party libraries without bundling them with source code
  • Reduce extension conflicts and compatibility issues by using a component-based architecture with robust dependency management
  • Adhere to PHP-Framework Interoperability Group (FIG) standards
  • Repackage Magento Open Source with other components
  • Use the Magento software in a production environment

You must create a Composer project from our metapackage if you want to use the Magento Web Setup Wizard to upgrade the Magento software and third-party extensions.

Prerequisites

Before you continue, you must do the following:

Get the metapackage

To get the Magento metapackage:

  1. Log in to your Magento server as, or switch to, the Magento file system owner.
  2. Change to the web server docroot directory or a directory that you have configured as a virtual host docroot.
  3. Create a new Composer project using the Magento Open Source or Magento Commerce metapackage.

    Magento Open Source

    1
    
     composer create-project --repository=https://repo.magento.com/ magento/project-community-edition <install-directory-name>
    

    Magento Commerce

    1
    
     composer create-project --repository=https://repo.magento.com/ magento/project-enterprise-edition <install-directory-name>
    

    When prompted, enter your Magento authentication keys. Public and private keys are created and configured in your Magento Marketplace.

    If you encounter errors, such as Could not find package... or ...no matching package found, make sure there are no typos in your command. If you still encounter errors, you may not be authorized to download Magento Commerce. Contact Magento support for help.

    See troubleshooting for help with more errors.

    Magento Commerce customers can access 2.3.x and 2.2.x patches two weeks before the General Availability (GA) date. Pre-release packages are available through Composer only. You cannot access pre-releases on the Magento Portal or GitHub until GA. If you cannot find these packages in Composer, contact Magento Support.

Example - Minor release

Minor releases contain new features, quality fixes, and security fixes. Use Composer to specify a minor release. For example, to specify the Magento Commerce 2.3.0 metapackage:

1
composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.3.0 <install-directory-name>

Example - Quality patch

Quality patches primarily contain functional and security fixes. However, they can also sometimes contain new, backward-compatible features. Use Composer to download a quality patch. For example, to specify the Magento Commerce 2.3.3 metapackage:

1
composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.3.3 <install-directory-name>

Example - Security patch

Security patches contain security fixes only. They are designed to make the upgrade process faster and easier.

Security patches use the Composer naming convention 2.3.2-px. Use Composer to specify a patch. For example, to download the Magento Commerce 2.3.2-p1 metapackage:

1
composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.3.2-p1 <install-directory-name>

Set file permissions

You must set read-write permissions for the web server group before you install the Magento software. This is necessary so that the Setup Wizard and command line can write files to the Magento file system.

1
2
3
4
5
cd /var/www/html/<magento install directory>
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data . # Ubuntu
chmod u+x bin/magento

Install Magento

There are two options for installing Magento:

  • Command line
  • Web Setup Wizard

Command line

This example assumes that the Magento install directory is named magento2ee, the db-host is on the same machine (localhost), and that the db-name, db-user, and db-password are all magento:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
bin/magento setup:install \
--base-url=http://localhost/magento2ee \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1

You can customize the Admin URI with the --backend-frontname option. However, we recommend omitting this option and allowing the installation command to automatically generate a random URI. A random URI is harder for hackers or malicious software to exploit. The URI displays in your console when installation is complete.

For a full description of the CLI install options, refer to Install the Magento software from the command line.

Web Setup Wizard

As an alternative to the CLI, use your browser to navigate to Magento’s setup wizard:

1
http://<Magento-host-or-IP>/<path-to-magento-root>/setup

For example: http://localhost/magento2ee/setup

You cannot use the Web Setup Wizard if your docroot is set to the pub/ directory. See Modify docroot for security.