How to install Magento 2 on Xampp localhost step by step


Recently, there are many requests from Magentoexplorer readers about tutorial to setup Magento 2 on Xampp so that we will have Magento 2 testing environment on Localhost. Today I will write about how to install Magento 2 on Xampp server Local host so that you can test Magento 2 right on PC.

Magento 2 requires Composer to install, let me explain why: Composer allows us to better manage Magento 2 system. Previously, when Composer wasn’t available, when you want to use a Magento library, you will need to download that Library and put to folders of your Magento project and that is very inconvenient. In Magento 2, Composer allows you to use library easily by just declaring and Composer will automatically download it to your Magento 2 folder.

Now we will go step by step how to install Magento 2 on Xampp

Step 1: Install Xampp server

This is simple, just like install a normal Windows program. Go to to download and install the latest XAMPP server on your PC

Step 2: Download Magento 2

You can download latest version of Magento 2 here:

Upon finishing, unzip all files/folders of Magento to  C:\xampp\htdocs and open XAMPP server and start Apache and Mysql as below:

Xampp for magento 2

Step 3: Installing Composer

You can download Composer here:

This installer will install the latest version of Composer and set up path so that you can call Composer from any directory using command lines

Now follow these steps to install Composer

composer setup magento 2


Click on Next and select Install Shell Menus

composer setup magento 2 - 2

Click on Next, now the install will ask for folder that contains php.exe file. By defaul the install will do this for you, however if you need, php.exe is located in  C:\xampp\php

php exe file

start composer install

Click on install to finish setting up Composer

complete composer setup


After the installation is finished, you must enable (php_intl.dll) in php.ini. Open php.ini in C:\xampp\php and uncomment the line by removing “;” before “extension=php_intl.dll” then save the file.

Next, open Magento 2 folder in htdocs, hold “Shift” + Right click and select “Open command window here” to open CMD window. Now type in:  composer install  to start install Magento 2 to your PC

Note: if you get error, go back to Magento 2 folder in htpdocs and right click to composer.lock => Select “composer update” then start over the installation

magento 2 install cmd 1


magento 2 install cmd 2

Now the program will ask for your Magento username and password, username/password is not your login account, you must get Secure Keys to enter to this field. Secure Keys can get in > My Account>Secure keys(under developer section on the left). Here you can see Public Key and Private Key. Puclic key = Username and Private key = Password, use these values to proceed Magento 2 installation (Generate new if you don’t have)

magento secure key

Next, go to PHPmyadmin to create a new Database for your Magento 2 site, on your web browser, go to

create database phpmyadmin

Note: to avoid errors during Magento 2 installation, open php.ini in C:\xampp\php and edit these lines:

Search for:  always_populate_raw_post_data , remove “;” before the line and change it to   always_populate_raw_post_data = -1 . Next, open XAMPP => restart Apache and Mysql to apply the changes.

Step 4: Install Magento 2

Enter Magento 2 URL to your browser, for example: localhost/Magento2

enter magento 2 url

Click on Agree and Setup.

magento installation 1

Now Magento 2 will start to check if system requirements to install Magento 2

magento installation 2

In Add a Database Step, enter Database information you created in PHPmyadmin (you can use root username to avoid error with mysql privileges) leave Database password blank.

magento installation 3

In Web Configuration, you can setup URL, Admin URL and some other options.

magento installation 4

In customize your store step, select timezone, currency and language you want to use on your store

magento installation 5

Next, create  Admin account to manage your store

magento installation 6

magento installation 7


Wait for the installation being processed. When the installation is successful, go to the URL to emter your Magento store

magento installation 8

Congratulation, you have successfully installed Magento 2!

1st note: If you encounter error with Magento 2 Admin URL, go to PHPmyadmin, search for “core_config_data” and changes these 2 values

  • web/unsecure/base_url  to
  • web/secure/base_url  to

2nd note: If you have error with site’s appearance, no css is loaded or image quality is bad, open Magento 2 folder in C:\Xampp\htdocs, hold Shift + Right Click => Open Windows Command here => Enter this command  php bin/magento setup:static-content:deploy  to get it fixed

Drop a line if you need and help.

Good luck with the installation!


How to install Magento 2 on Xampp localhost step by step
5 (100%) 2 votes


About Author

Brian is a Magento developer with 5 years of experience with customizing Magento extensions, Magento templates. He's main author at Magento explorer

Leave A Reply