In this post, we will see how to setup Magento2 on a Windows machine.

We will be using XAMPP for this. Here are the steps:

  1. Download and install XAMPP
  2. Download Magento2 zip file with sample data.
  3. Create a new database named magento2 in MySQL
  4. Create a new folder named magento2 (or any name you want) in xampp\htdocs folder.
  5. Open the following file in a text editor:
    xampp\apache\conf\extra\httpd-vhosts.conf
  6. Add following entry in the file:
    <VirtualHost *:80>
       DocumentRoot "C:/xampp/htdocs/magento2/"
       ServerName mag2.com.local
    </VirtualHost>

    This will allow us to call our Magento 2 web application with the URL:

    http://mag2.com.local
  7. Now, we will tell our operating system about our new URL which should be executed on localhost. Open the following file in a text editor as administrator:
    c:\Windows\System32\drivers\etc\hosts

    Add following line to it:

    127.0.0.1       mag2.com.local
  8. Next, we will run the Magento2 installer by visiting the following URL in our browser:
    http://mag2.com.local

    I assume Apache and MySQL are running and we already created our database.
    Installation is an easy process and you just have to fill some values like database name, mysql user etc.
    The installer might tell you to make some changes to your xampp\php\php.ini file.

  9. After installation, simply restart Apache in XAMPP and visit the URL:
    http://mag2.com.local

    You might see images missing and various errors in console. To fix this, start command prompt and move to your magento2 folder. Now execute the following command:

    php bin/magento setup:static-content:deploy

    Remove everything from your var folder and refresh the page.