Magento 2 installation guide

A long-waited Dev Beta of Magento 2 (0.42.0-beta1) appeared on Magento repository today. Of course we couldn’t sit still and installed Magento 2 on our server. And described the installation process for you, including the issues we dealt with and how we fixed them.

Precheck

The first steps lead us to the installation guide page. It is highly important to check whether your server suits minimal Magento 2 requirements:

Apache: 2.2 or 2.4

PHP: 5.5.x or 5.6.x

MySQL: 5.6.x

Composer

As Amasty servers work on Debian Wheezy, we installed Percona Server 5.6 so the server suits minimal database requirements, and we already have a server with PHP 5.5.x support. Also you’ll need Git and Composer, install it if you haven’t done it before.

Use these commands for Debian Wheezy with root user permissions:

apt-get update
apt-get install git wget
wget -O /usr/local/bin/composer http://getcomposer.org/composer.phar
chmod +x /usr/local/bin/composer

Magento 2 download

Now it’s time to clone Magento 2 code from GitHub repository. http://magento2.local/ is the URL of our website, and the document root is /var/www/magento2. Use these commands if you don’t plan to install Sample data for Magento 2:

cd /var/www
git clone https://github.com/magento/magento2.git
cd /var/www/magento2
composer install

If you plan to install Sample data – refer to this link for details. As for now Magento 2 is still under development, the best variant is to read the latest documentation at Magento docs.

Note: right now (15.05.2015) Magento Sample data can’t be install due to an unknown bug.

[Progress: 269 / 272]
Installing sample data:

[Magento\Framework\Exception\LocalizedException]
Area code is already set

Thus, we advise to monitor known Magento 2 issues and submit bugs if you notice any.

File permissions

‘Admin’ user is the owner of all magento files on our server, and Apache web server runs on behalf of ‘www-data’ user. Magento 2 documentation describes the access permission settings for files and directories on the principle that the web server runs on behalf of the user which is the owner of all Magento files. Our opinion is: it’s not the best decision, as it can lead to security issues (as the web server has permissions to write and run the code) as well as issues with setting access permissions for third party developers (as you’re not logging in as www-data user). We normally use the following access permissions:

chown -R admin:www-data /var/www/magento2
find /var/www/magento2 -type f -print0 | xargs -r0 chmod 640
find /var/www/magento2 -type d -print0 | xargs -r0 chmod 750
chmod -R g+w /var/www/magento2/{pub,var}

If you’re going to install Magento from the web interface, then add write permissions for app/etc/ and vendor/:

chmod -R g+w /var/www/magento2/{app/etc,vendor}

Database

We created an empty database on our new Percona Server 5.6 (mysql56.local), and most probably you’ll need to replace the values with your own ones:

echo 'CREATE DATABASE `magento2` DEFAULT CHARSET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON `magento2`.* to `magento2`@`%` IDENTIFIED BY "magento2";' | mysql -h mysql56.local -u root -p

Magento2 installation

The first time we tried to install Magento 2 using the web interface, but the process froze on 93%. The second installation was conducted from CLI, and we got an error:

PHP Fatal error:  Maximum function nesting level of '100' reached, aborting! in /var/www/magento2/vendor/zendframework/zend-code/Zend/Code/Scanner/DocBlockScanner.php on line 201

This is a known issue, and it is connected with xdebug PHP extension, which is installed on our server. To fix this mistake we set xdebug.max_nesting_level = 500. The result was the successful installation of Magento 2 using the following command:

cd /var/www/magento2
php -d xdebug.max_nesting_level=500 -f bin/magento setup:install --base_url=http://magento2.local/ --backend_frontname=admin --db_host=mysql56.local --db_name=magento2 --db_user=magento2 --db_pass=magento2 --admin_firstname=Local --admin_lastname=Admin --admin_email=admin@example.com --admin_username=admin --admin_password=adminpswd --language=en_US --currency=USD --timezone=America/Chicago

If you use xdebug as we do, add the following lines to the /var/www/magento2/.htaccess file:

<IfModule mod_php5.c>
  php_value  xdebug.max_nesting_level 500
</IfModule>

If everything is correct, you will be able to log in the Magento 2 backend at http://magento2.local/admin/.

UPD We’re updating the article as we dig into installation of Magento 2 and Sample data.

Have you tried to install Magento 2 Dev Beta yet? What is your opinion? Meanwhile, check Amasty’s Magento 2 extensions here.

UPD 2 Please mind that this article is outdated as there’s a new and easier process of installing Magento 2.