Install XAMPP on Windows 7 and set up a virtual host

Installing XAMPP

Download XAMPP Installer for WIndows and install with default settings.

If you get a warning in XAMPP saying Skype is using port 80, do the following:

  • Stop all services and quit XAMPP
  • Open Skype
  • Tools -> Options -> Advanced settings -> Connection
  • Uncheck “Use port 80 and 443 as alternatives”
  • Run XAMPP as administrator

Setting up virtual hosts

  • Stop all services in XAMPP
  • Open Apache vhosts file located at: C:\xampp\apache\conf\extra\httpd-vhosts.­conf
  • First add a default virtual host buy adding the following code to the end of the file
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost

This will stop the URL http://localhost/ from redirecting to the first real virtual host we create. This is handy when you need to access a URL like http://localhost/newsite/wp/wp-admin to install WordPress etc.

  • Next follow the examples in the vhosts file and add this code to the end of the file after our default virtual host.
<VirtualHost *:80>
    ServerAdmin postmaster@bp.benpearson
    DocumentRoot "C:/xampp/htdocs/benpearson"
    ServerName bp.benpearson
    ServerAlias www.bp.benpearson
    ErrorLog "logs/bp.benpearson-error.log"
    CustomLog "logs/bp.benpearson-access.log" combined

This code will create a virtual host for bp.benpearson

  • Create the folder C:/xampp/htdocs/benpearson and put a test index.html in there.
  • Run notepad as an administrator
  • Open the Windows hosts file located at: C:\Windows\System32\drivers\etc\hosts (may need to select “All Files” to see the hosts file in the etc directory)
  • Add the following line to the bottom of the file (the space after the IP address should be a tab) :	bp.benpearson
  • Start XAMPP Apache service.
  • Go to bp.benpearson in a browser and you should see your test index.html.

Reference: How to set up XAMPP with virtual hosts (some instructions conflict with the above)

5 thoughts on “Install XAMPP on Windows 7 and set up a virtual host

  1. Shibu

    Hi Ben,

    I go through this tutorial and everything is fine. After finish the work I have run the from my browser. I just give my url is “”. When i enter into this in my browser its just redirect to “” . I’ve created “xml_api” folder in htdocs and also insert index.html.

    All the time i give the url, it will redirect to How to get rid of this issue? I want show my index.html file in the folder xml_api in htdocs. Please help me

  2. Daniel Mercado

    Hi my name is Daniel, I am newbie in wordpress I want to learn and experience the trending of web editing. after setting all this stuff installing xampp, how I will run wordpress, please it would be my credit to you sir for your kindness and reaching those people who is in need your knowledge specially in the field of computer world. please teach me. my email is

    1. Ben Pearson Post author

      Hi Daniel. Try or or the Lodge on They have everything you need. Good luck.

Comments are closed.