If you want to insall Magento 2 version using composer then follow these three simple steps. If you already install the composer then you can use these steps, otherwise first insall the composer then follow these steps.

Let’s start

Step 01:
To install magento 2 open source (community) version:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition "install-directory-name" 

To install magento 2 commerce version:

composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition "install-directory-name" 

To install latest magento 2 open source (community) version:

 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition . 

To install spacific version of magento 2 open source (community) version:

 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.3.3

Step 02:
Create database

echo "CREATE DATABASE magento2_db" | mysql -u[mysql-user-name] -p

Step 03:

php bin/magento setup:install
–base-url=”http://magento-domain-name.com/”
–db-host=”localhost”
–db-name=”magento2_db”
–db-user=”db-user-name”
–db-password=”db-password”
–admin-firstname=”admin”
–admin-lastname=”admin”
–admin-email=”[email protected]
–admin-user=”admin”
–admin-password=”password123″
–language=”en_US”
–currency=”USD”
–timezone=”America/Chicago”
–use-rewrites=”1″
–backend-frontname=”admin”