Magento 2 2/25/2016

Magento 2: Installation

Experience shows that even established Magento developers face a number of stumbling blocks when they install Magento 2 for the first time. We have reported of our first experiences at the Magento hackathon in Zurich (October 2015). In order to make it easier for you to get started with Magento 2, we have summarised our experiences and learnings. We advise you to calculate at least 2-3 hours for your first Magento 2 installation.

For details regarding the single steps, please refer to the official documentation. Each step provides links to the documentation's corresponding chapter.

Magento 2: System Requirements

Compared to Magento 1, the requirements are a bit higher:
  • PHP version 5.5 or (better) newer
  • MySQL version 5.6 (5.7 is officially supported; however, we experienced some troubles when using it)

Magento 2 Installation: Several Alternatives

There are several ways how to install Magento 2, which have consequences for the project's structure. We recommend to use the "Integrator/Packager" method, since this means that we will later be able to manage packages using Composer. In our opinion, this is the most flexible and professional way how to install Magento 2.

We initialise the project with Composer:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name>

During the installation you might be asked for your authentication keys. To get these, you need a Magento Connect account. If you don't know how to get these, have a look at the official documentation.

Now we might as well get ourselves a cup of coffee and watch Composer work.

After a successful installation it's good to take a look at the system and file permissions of Magento 2 on our development server. Otherwise we might run into problems later on, if automatically generated files cannot be written.

Indispensable: Magento's Command Line Tool

To initialise the database, we use the new Magento CLI (Command Line Interface). In some cases, you might have to make it executable:
cd <installation directory name> && chmod +x bin/magento
After that we can use it to install Magento 2:
bin/magento setup:install --base-url=http://awesome-shop.local/ --language=de_DE --backend-frontname=admin --db-host=localhost --db-name=DBNAME --db-user=DBUSER --db-password=DBPASSWORD --admin-email=john@doe.com --admin-user=johndoe--admin-password=PASSWORD --admin-firstname=John --admin-lastname=Doe
The Magento 2 documentation includes an overview of setup commands.

If you use XDebug, you might see the following error message:

PHP Fatal error: Maximum function nesting level of '100' reached
The solution is to increase the attribute xdebug.max_nesting_level in the php.ini file. In one case I witnessed that the value was properly set for the vHost, but ignored by the CLI. Here, I recommend to execute the installer named above with the corresponding parameters:
php -d xdebug.max_nesting_level[=250] bin/magento setup:install <args>
Afterwards, we let our host point to <installation directory name>/pub/ . If you are interested in the backgrounds, let me refer you to Alan Storm's blog.

Then, we activate the Developer Mode. Magento 2 should never be run in the Default Mode, which is a hybrid mode that isn't helpful to anyone really. For further information on modes, take a look at the documentation, or again visit Alan Storm's blog.

Sample Data

In contrast to Magento 1 the optional sample data is added after installation. This is done by the following command:
bin/magento sampledata:deploy

Magento 2 Installation Completed

After the finished Magento installation, the store is ready for further development and use. In our blog, you find further posts regarding Magento 2 and how you can proceed from here, for example by setting up the frontend workflow for changing the store's parts visible to customers.