Magento 2 Tutorials

Installing Magento 2 With Composer

Thinking of installing Magento 2 with Composer, but not sure how to do it? You’ve come to the right place!

There is official documentation on how to do it, so this is merely an alternative step-to-step guide if you want to skim without reading the documentation thoroughly. We plan to keep this guide updated with newer Magento 2 code drops.

Before installing check the Magento 2 installation requirements.

Steps to Install Magento 2 with Composer

1. Install Composer

You can skip this step if you have Composer already installed. Windows users have an installer available.

1.1 Make Composer Globally Available

If you wish, you can additionally install Composer globally so you don’t have to type php/path/to/composer.phar every time. The Windows installer will automatically set up the PATH system variable.

2. Download Magento 2

Run the following command in root directory.

3. Set Up Permissions

After all the dependencies are retrieved, you should set the correct permissions on the entire Magento 2 installation directory. The official documentation recommends chmod’ing all directories to 700 and all files to a level of 600:

In case you are still facing problems, you are probably logged in under a different user and have to give ownership of the installation directory to the web server user.

4. Create The Database

Given that you already have a MySQL user with the correct permissions, then create an empty database to work with. If you want to, you can also use an existing database and pick a table prefix during the installation process, but that’s not something a lot of people do.

5. Install Magento 2

That’s about it! You can now follow the installation wizard or use the command line.

5.1 Installation Wizard

Just fire up the browser, navigate to the host where you installed Magento 2 and if everything went correct, you should be redirected to the setup tool.

5.2 Command Line Installer

Magento 2 ships with a command line installer and can be invoked as followed:

The above command should be edited to your needs and executed from the Magento 2 root directory. What follows, is a bit of scrolling text and if everything went correct, you are informed that the installation has been completed.

 Final words

Hopefully, this is a clear guide on how to install Magento 2 with Composer. Most of this information is simplified and readily available with more depth in the official documentation. In case we missed anything or you’d like to know more about, you can always leave a comment below, and we’ll get back with a solution!

Follow us on Twitter →

  • Thanks for the tutorial, very helpful. Are you sure that it’s possible to set up sample data after running the installer? In Magento 1 it was not as far as I know.

  • Nice :-) Thank you

  • Great writeup! Thank you.

    NB: Quick fix >

    php setup/index.php

    should read

    php setup/index.php install

  • project test

    Hi,
    I have installed magento 2 succesfully but it’s very vevery slowly. Do you know why ?
    Thanks

  • David Diomede

    Thanks for the tutorial, it was helpful. Easier to use https to clone the repository. Kept getting authorization errors any other way.

  • Afroz Alam

    It was a nice explanation. Can we have steps to install the stable version of Magento 2.0 as it has been already released ?

  • Ayushman Shrestha

    Hi, I was thing to configure Magento 2 in Ubuntu, with the permission setup as you mentioned “find . -type d -exec chmod 700 {} ; && find . -type f -exec chmod 600 {} ;” having trouble on theme development. Is it necessary to apply it during development, I believe we can go with that permission setup on Production environment? I tried to change the folder permission for applying for theme development lost access to my administrator panel then after. Please advise.

  • Sugan Hudda

    Hello,

    i use same method like magento1.9 . simple upload all magento code in htdocs folder magento2 and start installing and its completed and running…but i want to ask is it Right way? or its wrong..? i did not use composer.
    Kindly let me know. i am new in magento2.0

  • Sugan Hudda

    may i know, why we need to run composer? i think its completed compare to magento1

  • Sugan Hudda

    Hi Nick,
    Do you know about magento2, could we install without composer? i did install without composer. but not sure is it right or not

  • Sugan Hudda

    how to re-indexing magento 2 at localhost xampp? when i run command than showing error.
    you may not have proper read+execute permission tories under to var/generation magento2

  • Riddhi

    Hello,

    I have followed all the steps. But when i am running below command
    php setup/index.php install
    –db_host=localhost
    –db_name=mage2
    –db_user=root
    –db_pass=
    –backend_frontname=admin
    –admin_username=admin
    –admin_password=admin1020
    –admin_email=riddhi.shah@brainvire.com
    –admin_firstname= Developer
    –admin_lastname= Test
    –base_url=http://192.168.10.235/mage/
    –base_url_secure=http://192.168.10.235/mage/
    –language=en_US
    –currency=USD
    –use_rewrites=true
    –use_secure=false
    –use_secure_admin=false
    –cleanup_database

    It is not working for me and says that use “bin/magento” instead. I am installing magento2 for windows. Can anyone please tell me that how can i configure mydatabase for magento2 through command line.

  • RR

    Great article. I would like to say that the parameters for 5.2 should be changed to something like this: php bin/magento setup:install –db-host=localhost –db-name=magento –db-user= –db-password= –backend-frontname= –admin-user= –admin-password= –admin-email= –admin-firstname= –admin-lastname= –base-url= –language=en_US –currency=USD –use-rewrites=1 –use-secure=0 –use-secure-admin=0 –cleanup-database