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 https://getcomposer.org/installer | 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=https://repo.magento.com/ 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
--base-url="http://demo.com/"
--db-host="localhost"
--db-name="dbname"
--db-user="root"
--db-password="1234"
--admin-firstname="admin"
--admin-lastname="admin"
--admin-email="user@example.com"
--admin-user="admin"
--admin-password="admin123"
--language="en_US"
--currency="USD"
--timezone="America/Chicago"
--use-rewrites="1"
--backend-frontname="admin"


6. Install sample data

Run below command

php bin/magento sampledata:deploy

Problem:

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

</Directory>