How to Install Magento 2 via Composer
You might have seen that on Inchoo Ivan Veres describes how to install Magento 2 with the help of various methods. He sheds light on the three following approaches: installation from archive file, via Composer, and via GitHub. Ivan says that the described methods are aimed at those Magento enthusiasts who want to have more troubles in their lives. Is he right? We think that you can argue with Ivan, especially in case of archive installation, but he is right to some extent, since it is obvious that Magento 2 installation is not everyone’s business. But if you are brave enough, we’d like to draw your attention to installation via Composer. Two other methods are described here: How to Install Magento 2 from Archive File and How to Install Magento 2 via GitHub.
This Magento 2 installation guide shows how to cope with the best ecommerce platform installed on Linux Ubuntu 16.04 with PHP 7.0.7, Composer 1.1.2, and MySQL 5.7.12. And don’t forget about a virtual host. It will help you rule all Magento 2 installations. Ivan’s ones can be found under http://m2.loc/2.07/.
How to Install Magento 2 via Composer
If you are not familiar with Composer, it is a tool for dependency management in PHP. For further information, check the
As for the Magento core code, it is stored under the /vendor directory just like in case of the archive installation. Note that updating is possible through the admin interface as well. So, let’s start the installation without sample data.
1. Login to your Magento account.
2. Obtain authentication keys
- Go to “My Access Keys”
- Enter “Name”.
- Generate new keys.
3. Open terminal.
4. Run the following command:
1 |
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition |
5. Use your public key as a username.
6. Use your private key is a password.
Now, Magento 2 is ready to be installed. There is Setup Wizard willing to help you, so our participation is no longer necessary until you want to install sample data.
1. Open terminal.
2. Go to the Magento 2 root directory.
3. Enter these commands:
1 2 |
php bin/magento sampledata:deploy php bin/magento setup:upgrade |
The composer.json file will be updated and and sample data will be installed.
In case you see the following message – “Please re-run Magento compile command”, utilize terminal once again: run the following command:
1 |
php bin/magento setup:di:compile |
Some time is necessary to complete the procedure.
For further information, check the official