Install Magento2

  • 1st way:

Install by downloading source code from git repo or Magento download page.

Download source and run from browser or using the command line.

  • 2nd way(Recommended and best):

Using composer. follow below step for it

1. Install composer if not installed yet. you can check it by below command

composer --help

if it shows result that means composer is there. if not display result or display error install it by following the way

a. run below command from terminal

curl -sS | php
mv composer.phar /usr/local/bin/composer

b. Make your composer global

mv composer.phar /usr/local/bin/composer

2. Run below command to install Magento community latest version

composer create-project --repository-url= magento/project-community-edition .

3. Setup proper file and folder permission

find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {} \;

4. create database using command or directly from phpmyadmin
5. Run below command with proper data filled

php bin/magento setup:install

6. Install sample data

Run below command

php bin/magento sampledata:deploy


CSS and Js is not loading after installation of fresh Magento

Enable rewrite using below command

a2enmod rewrite

And Open /etc/apache2/apache2.conf


Find <Directory /var/www/>

Replace rules inside with below rules.

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted