Just like Magento 1, the installation of Magento 2 can also be done via a composer. This is the most effective way to install as well as support/upgrade Magento 2. All files, modules, and libraries are automatically copied and prepared for setup via composer.
In order to install Magento 2 via composer, follow the below steps:
Composer project creation
The Magento 2 Community Edition 2.3.4 can be set up in the current directory using the below command:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:2.3.4 --prefer-dist --ignore-platform-reqs --no-interaction --dev
Version 2.3.4 can be changed to any other accessible Magento 2 version (2.3.0, 2.3.7, 2.4.2, etc) by changing the parameter ”–repository-url”.
Setting Up Magento 2
Once you have copied Magento via composer, you must run Magento's own setup command below:
php bin/magento setup:install --base-url=http://localhost.com/
--db-host=localhost --db-name=<db> --db-user=<db-user> --db-password=<db-password>
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com
--admin-user=admin --admin-password="<password>" --language=en_US
--currency=USD --timezone=America/Chicago --use-rewrites=1
--search-engine=elasticsearch7 --elasticsearch-host=<elasticsearch-host>
--elasticsearch-port=<elasticsearch-port>
For this command, there are some parameters that you need to specify (or you can simply replace the default values, mentioned above):
For More Information, Visit:- https://www.magespark.com/blog/post/how-to-install-magento-2-via-composer?utm_source=writeupcafe&utm_medium=article&utm_campaign=july-2022