Unfortunately, when you use Internet Information Server on a Windows XP Professinal computer, it is not possible to have multiple sites with different base-URL’s. The only available base-URL is http://localhost and you must differentiate by folder structure from there on.
Fortunately there is the Apache HTTP Server Project. With this webserver you can have multiple base-URL’s on a single computer.
Here is how you do it:
Getting the necessary files
Install the Apache HTTP server
You can download the software at the website of the project which is here. I downloaded the 2.0.59 release using this link.
Installation on Windows is simple. Just download the binary version which is an installer package and execute it.
Configure for multiple base-URL’s
Configure Windows
I used Windows XP Professional. Go to the operating system installation folder (typically c:/WINDOWS) and navigate further down to system32/drivers/etc
Open the file “hosts” with Notepad and add a line which maps the base-URL you want to the local IP address. This goes like following:
So, at the end my file lookes like this:
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
127.0.0.1 mysite
Configure the Apache HTTP server
In the windows startmenu, navigate to
- Apache HTTP Server 2.0.59
- Configure
and choose the “Edit the Apache httpd.conf Configuration File” entry. You will now have Notepad open with the file http.conf.
Navigate to the end of the file where you will see following lines:
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn’t need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.0/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option ‘-S’ to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
Remove the # from the line “#NameVirtualHost *:80”, so you get:
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn’t need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.0/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option ‘-S’ to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
Add following to the end of the file:
ServerAdmin webmaster@mysite.com
DocumentRoot “F:\Serge\My Web Sites\folderformysite”
ServerName mysite
ErrorLog logs/mysite.error_log
CustomLog logs/mysite.access_log common
</VirtualHost>
The doumentation of the server mentions that you must remove the # in front of the line with “NameVirtualHost *:80”. Allthough I suggest you do this, it worked for me without doing it.
Setup your website
Make a simple HTML file and place it in the folder you used for your website. In the above example this is the folder “F:\Serge\My Web Sites\folderformysite”. You can name teh file “sample.html”
Open your browser and type following URL:
“http://mysite/sample.html”
If everything went fine you should now see the page you made.
Resources
[1] Apache HTTP Server
[2] The documentation for the <VirtualHost> tag
Updates
6 Januari 2007: original version