Magento2 Installation – Getting Started

In this blog we are going to see how to install magento2 and the various options we have for installation.

Getting Started

There are many ways to install magento2 which you can find here

In this post, we will only see the most easiest way of installation.
There are two ways you can choose
1. Installation with SSH/Terminal Access
2. Installation on shared hosting (without terminal access)

For magento2 it is recommend to have a terminal access because magento2 has an rich set of commands in its new command line interface.

Installation with SSH

There are two repository’s which you can use to install magento2
1. https://github.com/magento/magento2
2. https://github.com/magento/magento2-community-edition

For developers the first repository is recommended, i.e your looking for module development etc.
But if you just need to install magento and work with admin features etc i would recommend the second repository.

We will see how to install magento2 via terminal

Step1 – Setting up git and composer

Create a new directory for your magento installation or go to your apache root directory
Run below command in your directory

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

This will clone the git repository. After this is complete, you need to setup auth.json in your root folder. Just create a new file auth.json in root directory with content like this

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

You can get the value of username/password for the secure keys section in your magento connect account. You can see details of this here

Once you have done this run the command

composer install

If you have not installed composer before, install it using the guide here

After the above process is done, composer will install all the relevant module required for magento2. At this step you have all the required files to start magento2 installation.

You need to php version 5.6+ for magento2. To update php on ubuntu follow this link

If you get error’s like these
Problem 1
– The requested PHP extension ext-intl * is missing from your system. Install or enable PHP’s intl extension.
Problem 2
– The requested PHP extension ext-xsl * is missing from your system. Install or enable PHP’s xsl extension.

Do the following

sudo apt-get install php5-intl
sudo apt-get install php5-xsl
sudo service apache2 restart

Step2 – Permissions

Now you need to configure the permissions for different folder in magento2. Magento2 has a auto-generation system in which it generates files for performance. So setting folder permissions is very important or else you might get many errors.

sudo chmod -R 777 var/
sudo chmod -R 777 pub/static
sudo chmod -R 777 pub/media
sudo chmod -R 777 app/etc

Also make sure all folders are owned by apache user. This is mostly the case by default, but you need to confirm. You can also set to particular user/group using

sudo chown -R {user}:{group} *

make sure to use user and group with correct values.
See more about permissions here

Step3 – Setup Wizard

Open the url http:////setup
This should start the magento installation wizard, proceed with the steps to complete the installation.

There is also another method to install magento via command line but i suggest setup wizard is better.


1. You might get this error during installation
Your PHP Version is 5.6.20-1+deb.sury.org~trusty+1, but always_populate_raw_post_data = 0. $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. This will stop the installer from running. Please open your php.ini file and set always_populate_raw_post_data to -1. If you need more help please call your hosting provider.

To fix this open the php.ini (typicall located at /etc/php5/apache2/php.ini) which you can find by looking at php_info() output.

Find the line

 always_populate_raw_post_data = 0

and change it to

 always_populate_raw_post_data = -1

Then restart your apache server (typicall sudo service apache2 restart) to fix this issue

2. You might get an error to upgrade mysql version 5.6 to do so follow this process here

To install via command line run this

php bin/magento setup:install --base-url=http://<your-domain->/<magento_dir>/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1

fill in the correct values for database etc

Installation on shared hosting

If you have a shared hosting and no command line. Directly download latest magento version from https://magento.com/developers/magento2
Upload the file to your server through ftp and then unzip it there.
Follow same process from step2 as mentioned above

  • I am a fresher in Magento programmig and while installation I was getting issue. I searched a lot and finally I got this blog which has helped me with the issue I was getting while installation. Thanks for being my problem solver. 🙂