How to install Magento 2

installing magento

When installing Magento 2 on your machine you should ask yourself:

  • Do I need more problems in my life?

If answer is Yes, continue reading.

I’ll be installing Magento 2 on my dev machine – Linux Ubuntu 16.04 with

  • Php 7.0.7
  • Mysql 5.7.12
  • Composer 1.1.2

Before continuing, make sure you have all the prerequisites, required for running Magento 2.

I set up one virtual host, to rule them all! That way all my Magento 2 installations will be found by this local link http://m2.loc/2.07/ for you to follow along.

As you may, or may not already know, there are a few ways to install it. I will go through each installation, with and without sample data.

Install from archive file

First and easiest way is to download it from Magento download page
https://www.magentocommerce.com/download

You can choose from few different archive types (zip, tar.gz, tar.bz2) , with and without sample data.
Magento was kind enough to pack with all composer dependencies in the archive, so you don’t have to run Composer.

In this installation Magento core code is stored under /vendor directory and updating is possible through Magento admin.

So next steps are easy, just visit http://m2.loc//2.07/magento-website/ (in my case) and follow Setup Wizard.

Install via Composer

Second, but not the last, is installing Magento via composer. Composer is a tool for dependency management in PHP. To learn more visit this link https://getcomposer.org/doc/00-intro.md

In this installation, Magento core code is also stored under /vendor directory and updating is possible through Magento admin.

First you need authentication keys which can be obtained here, and you will need Magento account to login.
Once logged in, go to “My Access Keys”, enter some descriptive “Name” and generate new set of keys. Magento uses this approach because, in future, extensions you buy from marketplace, will be available to you, through Magento admin interface.

Enter this command in terminal:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition

When prompted, your public key is username, and private key is password.

After that, Magento is ready for installation. Go through Setup Wizard and install it.

This was without sample data. So to install sample data, navigate to your Magento 2 root directory through terminal, and run the following command:

php bin/magento sampledata:deploy
php bin/magento setup:upgrade

These two commands will update your composer.json file and install sample data. If you get this message, after installing sample data – “Please re-run Magento compile command”, enter the following in terminal:

php bin/magento setup:di:compile

This command will take some time to complete.

Install via GitHub

Third, and the last one, is cloning or downloading release from GitHub repository.
In this installation, I will show you how to avoid setup wizard and install Magento through terminal. But, it is important to mention that in this installation Magento core code is stored under app/code not in vendor/ like in previous two examples.
When you try to update Magento through Admin interface, you will get error that this is a GitHub version and it’s not possible to update. GitHub releases are intended to be used by contributors/developers.

First we must clone Magento repo from here: https://github.com/magento/magento2 or you can download releases on https://github.com/magento/magento2/releases

Create empty directory and run:

git clone git@github.com:magento/magento2.git .

After deploying has been finished, run:

composer install

Now it’s time to install Magento 2. My setup looks like this:

php -f bin/magento setup:install –base-url=http://m2.loc/2.07/github/ --backend-frontname=admin
--db-host=localhost --db-name=m2git --db-user=root --db-password=inchoo --admin-firstname=Magento
--admin-lastname=User --admin-email=ivan.veres@inchoo.net --admin-user=admin --admin-password=magento123
--language=en_US --currency=USD --timezone=America/Chicago –use-rewrites=1

Change your base-url, db-name, db-password, admin-email, admin-password to match your local setup.
If your visit you local link through browser (http://m2.loc/2.07/github/), Magento 2 should be installed.

If you need sample data, follow along.
In your web root (not magento2) run:

git clone git@github.com:magento/magento2-sample-data.git

Navigate into cloned directory and execute:

php -f dev/tools/build-sample-data.php -- --ce-source="your Magento CE install dir"

This will create symlinks to your Magento 2 installation.
Set ownership and permissions if you are on Linux machine:

chown -R :your web server group name
find . -type d -exec chmod g+ws {} \;

Then you need to clear static files (cache).
Navigate to Magento 2 var/ folder and enter following:

rm -rf cache/* page_cache/* generation/*

In Magento 2 documentation there are no further instructions. However you need to install sample data.

php bin/magento setup:upgrade
php bin/magento setup:di:compile

After that you should have sample data installed.

If you have some problems reference at: http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html


About Ivan Veres

Backend Developer

Ivan is a Backend Developer who has equal amounts of love for programming, paragliding and weekend barbecues near the lake.

Read more posts by Ivan / Visit Ivan's profile

7 comments

  1. Hi Ivan,

    this is the message that I see after the github installation: Magento supports PHP 5.6, 7.0.2, and 7.0.6 or later.

    thanks

  2. Thank you very much Ivan, Its worked.

    I have followed so-many tutorials and even magento articles too but nothing helped effectively but this one really helped no issues I used Composer installation and sample data as-well.

    I think recently there are some slice changes are released by magento for install process so some-of old installing tutorials/articles not works well.

    Again Thanks for your effort!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.