Setting up Virtual Sites with Apache Web Server on Windows

Add a comment October 10th, 2007

This tutorial will guide you through installing Virtual Sites for Apache Web Server. This is applicable only if you planning to built your web application not from http://localhost.

Below listed are the series of steps that will allow you to add virtual sites:

Here i am trying to add dev.hiteshagrawal.com. Before doing this make sure to create a backup of the files that will be edited to create virtual site just in case if anything wrong happens to the system.

Your email:

 


Step1 – Edit the Host File:

  • Edit the “hosts” file available at the windows folder\system32\drivers\etc

Example:
C:\Windows\system32\drivers\etc\hosts – Win98, WinXP, WinME
C:\WinNT\system32\drivers\etc\hosts – WINNT based OS

  • Open the “hosts” file in a Text Editor. You will find entries at the end similar to 127.0.0.1 localhost. Below this statement add this line
    127.0.0.1 dev.hiteshagrawal.com
    Now save the file.

Step 2 – Update Apache Web Server Configuration File
The next step involves configuring Apache Web Server to know him that it also needs to accept requests for http://dev.hiteshagrawal.com.
Open the Apache Web Server configuration file (httpd.conf) located at “apache root folder/conf”.
Example if your Apache Web Server Folder is on C Drive then the path would be C:\Apache2.2\conf\httpd.conf

Now you need add the following code inside the httpd.conf file.

    <virtualhost *:80>
        DocumentRoot "/websites/hiteshagrawal.com"
        ServerName dev.hiteshagrawal.com
    </virtualhost>

Your email:

 


Step 3 – Giving Permission to the Virtual Folder
Now you need add the following code inside the httpd.conf file

<directory "C:\websites\hiteshagrawal.com">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</directory>

Step 4 – Cross Check to validate your changes
Create a file index.php in the Virtual Directory folder. Open your browser and type in the domain that you configured and index.php.
Here http://dev.hiteshagrawal.com/index.php


Popular Articles:

Subscribe to my RSS feed.

  1. December 1st, 2008 at 05:43 | #1

    I enjoy when read your posts, very good work! thnaks for all…

  2. March 21st, 2009 at 02:56 | #2
    Abhijit

    HI,
    I am using XAMPP as server application. I am trying to use the above procedure to host a website but confused with the following codes:

    DocumentRoot “/websites/hiteshagrawal.com”

    What does hiteshagrawal.com means here? Do i need to rename the folder where my web files are stored to foldername.com? If not then what to do…?

  3. June 29th, 2009 at 02:12 | #3
    Dan

    I wanted to allow database downloads from my D: drive, but I got this 403 error, this is how I solved it in my Httpd.conf

    Alias /db “D:\sqldata\backups”

    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order Deny,Allow
    Deny from localhost
    Allow from all

    Hope this helps

    Dan,
    Goto Euro DB Admin

  1. |
    January 22nd, 2009 at 00:29 | #1

    [...] Create Virtual Host/Website in Apache for Windows Found a very good link on creating virtual host/website in Apache Server: http://www.hiteshagrawal.com/apache/…ver-on-windows [...]

Comments feed

Spam protection by WP Captcha-Free