How to install Magento 2 on Xampp localhost step by step

7

Recently, there are many requests from Magentoexplorer readers about tutorial to setup Magento 2 on Xampp on Windows OS 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 https://www.apachefriends.org/index.html 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: https://www.magentocommerce.com/download

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: https://getcomposer.org/Composer-Setup.exe

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 Magento.com > 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 127.0.0.1/phpmyadmin.

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!

Troubleshooter

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 http://127.0.0.1/magento2/
  • web/secure/base_url  to https://127.0.0.1/magento2/

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
4.8 (96%) 5 votes

Share.

About Author

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

7 Comments

  1. Why use Windows when Debian has a better performance for PHP based apps? I have used Magento with Windows and Debian, but found that with Debian my Magento website was loading faster and had few performance issues. This could also be because I changed the host as well when moving to Debian. I hosted my website on Linux and I had a custom stack that included Apache, Varnish, memcached and other packages.

    • Hello there Kyler, as you know, most of us use Windows OS system to work so I write this tutorial for users who need to set up Magento on Localhost on Windows for development work.

  2. Hello Daniel,
    I am trying to deploy Mg2 on windows. But I got the following error trying to execute “composer install” command. Do you have any suggestions?
    Thanks,
    —-
    C:\xampp\htdocs\Magento2>composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Your requirements could not be resolved to an installable set of packages.

    Problem 1
    – magento/framework 100.1.3 requires ext-xsl * -> the requested PHP extensio
    n xsl is missing from your system.
    – magento/framework 100.1.3 requires ext-xsl * -> the requested PHP extensio
    n xsl is missing from your system.
    – Installation request for magento/framework 100.1.3 -> satisfiable by magen
    to/framework[100.1.3].

    To enable extensions, verify that they are enabled in your .ini files:
    – C:\xampp\php\php.ini
    You can also run php --ini inside terminal to see which files are used by PH
    P in CLI mode.

    • Hello Berg, you can fix this error by adding the argument –with-xsl[=DIR] to your configure line (DIR being the libxslt installation directory)

      If you are using XAMPP, go to your php root folder, Simply copy all icu* * * *.dll files:
      from C:\xampp\php to C:\xampp\apache\bin

      If you are using WAMPP
      Please copy the all files name like icu.*.*.dll from C:\wamp\bin\php\php5.5.12 to C:\wamp\bin\apache\apache2.4.9\bin.


      On Linux
      , you can run the following command in CLI

      intl extension will start working and the error will be gone!!!

    • Hello there,
      What PHP version you are using on XAMPP? You can check by create a php file containing this code:

      You can also go to XAMPP website and see what XAMPP version you are using, there you will find the corresponding PHPversion.
      Note: Magento 2 requires PHP 5.6.x, 5.5.x, where x is 22 or greater, 7.0.2, 7.0.6–7.0.x. Not supported: PHP 7.1, PHP 5.4

Leave A Reply