Install Magento 2 Using Composer

Before Magento 2.3.x, there is a way to install Magento 2 from the browser but with the latest Magento 2 version it’s not possible, you must have to use the command line to install Magento 2.

Before installation, You have to download Magento 2. Review our blog post on how to download Magento 2 using the composer

Below are steps to install Magento 2 using composer:

Step 1: Connect to the SSH of your Magento server with written permission.
Step 2: Run the below command to install Magento 2.

bin/magento setup:install \
--base-url=http://localhost/magento2 \
--db-host=localhost \
--db-name=database_name \
--db-user=database_username \
--db-password=database_user_password \
--admin-firstname=Vish \
--admin-lastname=Vaghela \ \
--admin-user=vish \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=elasticsearch7 \ \
--elasticsearch-port=9200 \
--elasticsearch-index-prefix=magento2demo \

NOTE: Change database_name, database_username, and database_user_password with your server database details.

Check all possible arguments of Magento install command using Advanced Install Steps