Install Magento 2 with Sample Data

You can install Magento in different ways. In this article, I will show you how to install Magento via GitHub.

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

Step 1: Clone Magento repository

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.

My document root folder location is  /home/vagrant/learning.portal/apps/magento2.blog.dev/public_html/src/web

So let’s clone the Magento repository in to the document root folder.

Step 2:  Update installation dependencies

To run Composer for the first time and install Magento packages, We need to run the following commend:

Step 3: Install Magento 2

Now it’s time to install Magento 2.

To install Magento 2, I am going to use Command Line Installer.

So, We need to run the following commend:

Change your base-url, db-name, db-password, admin-email and admin-password to match your local setup.

If everything went correct, you are informed that the installation has been completed.

If your visit you local link through browser (http://iyngaran.learning.magento2.blog.dev/), Magento 2 should be installed and you will be able to see the home page.

Also you should be able access the backend via following url with the user name and password

http://iyngaran.learning.magento2.blog.dev/admin

Username : admin

Password : iyngaran123

Step 4: Install Sample Data

Create a new folder called ‘sample_data’ in the Magento installation directory (/home/vagrant/learning.portal/apps/magento2.blog.dev/public_html/src/web)

Go into the sample_data folder.

Then let’s clone the sample data from repository.

After deploying has been finished, run the following command.

My Magento installation directory is : /home/vagrant/learning.portal/apps/magento2.blog.dev/public_html/src/web

So I am going to run the command as follows.

This will create symlinks to your Magento 2 installation.

After that, we need to set the ownership and permissions for the files and folders.

To set the ownership, let’s run the following command.

In my web server, the new-owner name : vagrant and new-group name : vagrant. So I am going to run the command as follows.

And then we need to set the folder permission. To do that, let’s go to the directory.

And run the following command to set permission to the folders.

Then let’s execute the following command to clear static files (cache).

And then we need to run the following two commands to install the sample data.

That’s it. Now you should have sample data installed. Now, If your visit you local link through browser (http://iyngaran.learning.magento2.blog.dev/), you should be able to see the pages with sample products, banners and etc.

Step 5: Set development mode to Magento

We need to remove the contents from following folders.

Let’s run the following command to remove the contents from those folders.

We can run the following command to display the current mode.

A message similar to the following displays:

Current application mode: default. (Note: Environment variables may override this value.)

Lets change to developer mode using the following command.

Following is a summary of messages that display:

Enabled developer mode.

Thats it. Now, we have installed the magento2 and it is on developer mode. Now we can godhead and do the customization.

I hope you find this tutorial useful!  🙂