Install Latest or Old version of Magento2 via Composer

December 23, 2020 | In: Magento, php

To get the Magento metapackage:

  1. Log in to your Magento server or localhost path where you would like to install the Magento. Make sure you have proper permissions to use that folder.
  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
composer create-project --repository-url= magento/project-community-edition <install-directory-name>

Magento Commerce

composer create-project --repository-url= 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.

Here, It will install a latest Magento version. In case, you want to install a old version instead of the latest version then you can mention the version number which you would like to install.

For example:

composer create-project --repository-url= magento/project-community-edition  <install-directory-name> <version-number>

So, it will look like:

composer create-project --repository-url= magento/project-community-edition /Applications/XAMPP/htdocs/magento2 2.3.0