This is the crash course tutorial for creating vhosts in your apache webserver for win32 (and even linux except for some windows specific configuration)
If you are a web programmer like me, you will probably be handelling many php/perl projects at the same time with your apache. Putting everything in `htdocs` is a headache because it will make it look very messy. So this is where vhosts comes into play. For most linux webservers, systems like ensim or plesk handle these things without letting the users know what is going on behind! Moreover apache's documentation might seem confusing.
Lets begin...
Lets assume we are creating a vhost called `subrat.example.com`
1. Go to your `X:\WINDOWS\system32\drivers\etc` folder
2. Open the file called `hosts` in notepad and add the following line to the end of the file and save the file.
127.0.0.1 subrat.example.com
3. Open your `httpd.conf` file and add the following line
## This line should be added only once
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:/Apache2/vhosts/subrat.example.com/httpdocs"
ServerName subrat.example.com
ServerAdmin subrat@myktm.com
ErrorLog logs/error.log
TransferLog logs/access.log
</VirtualHost>
4. See the `DocumentRoot` setting and change the folder path to some your new htdocs or httpdocs files. Feel free to manage your folders! Make sure the ServerName is the same as the vhost name u added in the `hosts` file. Every time u add an ip to `hosts` file u need to add the above <VirtualHost> tag and its sub flags.
5. Restart your apache and everything should go well if you followed the instructions carefully.
6. Fire up mozilla and try going to http://subrat.example.com/ and you should see your page.
There are other flags inside <VirtualHost> tag, you can do some research about it to add more functionality.
Have fun.