Installing Magento 2 for Development

There are two common ways to install Magento 2. One is to simply clone the Magento 2 GitHub repository and install. This is great for contributing, but not so much for starting a new project. Magento released the Magento 2.0 GA this Tuesday, November 17th at the MagentoLive Australia event. Very exciting stuff! With that they threw the switch on the new meta-packages server which hosts all you need to install Magento 2 with only a set of authorization credentials and composer. Well…almost. You’ll need to ensure your development environment supports this set of minimal technical requirements first:

  • PHP 5.5.x* / 5.6.1 (or later) / PHP 7 RC (that’s right…supports it right out of the gate!)
  • MySql 5.6.x
  • Apache 2.2 / 2.4 or Nginx 1.8 (or later)
Note: PHP 5.5.10 - 5.5.16 and 5.6.0 have a known bug which interferes with timezone support. PHP 5.4 is no longer supported. For a complete / detailed list of system requirements, head over to this page on devdocs.

So how do you get this software installed? Let’s get started…

Step 1: Make sure you have a set of authorization credentials for the Magento meta-packages set in your auth.json file. This is located in your COMPOSER_HOME directory, which by default in *nix system is ~/.composer/auth.json. Instructions on how to get these credentials can be found on this page. My auth.json looks about like this after I added my pair of credentials:

{
    "http-basic": {
        "repo.magento.com": {
            "username": "",
            "password": ""
        }},
    "github-oauth": {
    "github.com": ""}
} 

Step 2: Use composer to create a project and pull in all meta-packages, then cd in and adjust permissions. The first time you ever run this it will take a while. Subsequent runs will be blazing fast, as composer will cache the packages locally for later use! In my case, I’m installing the site at /sites/m2.demo:

composer create-project --repository-url=https://repo.magento.com/ \
    magento/project-community-edition /sites/m2.demo
cd /sites/m2.demo
chmod +x bin/magento

Step 3 (optional): Deploy the sample data so it will install along with everything else in the following step:

bin/magento sampledata:deploy
composer update

Note: You will see a composer error running sampledata:deploy on 2.0 GA due to a bug. The followup composer update call here is to workaround that issue.

Step 4: Create a new database and execute the setup:install command:

mysql -e 'create database m2_demo'
bin/magento setup:install --base-url=http://m2.demo --backend-frontname=backend \
        --admin-user=admin --admin-firstname=Admin --admin-lastname=Admin \
        --admin-email=user@example.com --admin-password=A123456 \
        --db-host=dev-db --db-user=root --db-name=m2_demo

Step 5: Make sure you have DNS properly configured and/or an entry in /etc/hosts, and that your Apache/Nginx is configured to work with the chosen webroot.

Step 6: Load up http://m2.demo in your browser and bask in the glory of Magento 2! It should look something like this:

Magento 2.0 GA - Homepage