How to install Magento 2 using composer and git in 5 minutes

In this article, I will show you how to install Magento using composer and git on your server or localhost.
First of all, make sure your server configuration meets the system requirements of Magento 2.Here you can check system requirements of Magento 2 Latest version

Let’s start Magento 2 installation
How to Install Magento 2 via GitHub

1. Go to your server root or directory where you want to install Magento 2 and open that folder in the terminal.

2. Copy following command and run it inside that folder in the terminal.
git clone

3. Wait until the clone download complete.

4. Now run  the following command:

composer install

5. Now run following command to give permission to cache and pub directory.

chmod-R 777 var/ pub/ generated/

and hit your root URL in the browser.
If you see permission error as shown in the following image then run the following command.

chmod -R 777 app/etc/

Now fill all the information and complete the installation


You can also fill that information and install Magento using the Magento install the following command in the terminal if you want to skip step 5.

Please change your db-user,db-password ,db-name and other parameter value according to your database details and magento configration.

php -f bin/magento setup:install –base-url=http://m2.loc/2.07/github/ --backend-frontname=admin
--db-host=localhost --db-name=yourdbname --db-user=root --db-password=yourdbpassword --admin-firstname=Zarvis
--admin-lastname=User --admin-user=admin --admin-password=magento1223
--language=en_US --currency=USD --timezone=America/Chicago –use-rewrites=1

6. Wait and Magento will installed in few minutes.
If you want to install the sample data then run the following command it clone

7. How to set permission to Magento 2 files and folder

chown -R :your web server group name

find . -type d -exec chmod g+ws {} \;

chown -R :your web server group name

find . -type d -exec chmod g+ws {} \;

8. Clear cache using follwoing command

Go to Magento 2 var/ folder
rm -rf cache/* page_cache/* generation/*

9. Run the following commands to install sample data:
php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:upgrade
php bin/magento setup:di:compile

If everything okay, your Magento 2 will be installed using the Magento sample data.

Please view the following video for magento 2 installtion

Any queries, ask in comments


Sign up for our newsletter to get Daily Updates

It is main inner container footer text