Sarathlal N

Install Magento 2 using composer

The Magento 2 can be installed in multiple ways. I like the composer way & below you can find the steps to install Magento 2 using composer.


  1. LAMP Server
  2. Composer
  3. Server access via SSH
  4. Valid Magento Authentication keys (Create authentication keys)

During installation, our command line interface will ask for Magento authentication keys. The public key is our user name & private key is password.

Create new project

composer create-project --repository-url= magento/project-community-edition web/

You have to update your installation directory in the above command. Mine it is web/ for my URL

Install Magento

php bin/magento setup:install 

I have added new lines in the installation command for better readability. Update the values in the installation command and remove the new lines.

It will look like below one.

php bin/magento setup:install --base-url="" --db-host="localhost" --db-name="my_dbname" --db-user="my_dbuser" --db-password="dbpassword" --admin-firstname="admin" --admin-lastname="admin" --admin-email="" --admin-user="admin_username" --admin-password="admin_password" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="my-admin-path"

Magento 2 will be installed and you can see message in your interface. You can confirm that by accessing its front end & back end.

Add sample data

The current installation is without sample data. If required, we can easily install sample data.

Go to project root folder

cd web/

Update our composer.json file & install sample data

php bin/magento sampledata:deploy
php bin/magento setup:upgrade

Compile installation after new changes

php bin/magento setup:di:compile

Recent Posts

  1. Solve "ValueError invalid literal for int() with base 10" - Python
  2. Handling dynamic subdomain with Flask - Python
  3. A minimal example about WordPress object cache
  4. Select random element from a list - Python
  5. Write our first Selenium program with Python 3 & Firefox

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.