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:
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
Click on Next and select Install Shell Menus
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
Click on install to finish setting up Composer
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
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)
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.
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
Click on Agree and Setup.
Now Magento 2 will start to check if system requirements to install Magento 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.
In Web Configuration, you can setup URL, Admin URL and some other options.
In customize your store step, select timezone, currency and language you want to use on your store
Next, create Admin account to manage your store
Wait for the installation being processed. When the installation is successful, go to the URL to emter your Magento store
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 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!