Tag Archives: Apache

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)