Apache Virtual Hosts II

httpd.conf

Next, you will open the httpd.conf file in the Apache folder; at the bottom end of the file, you will see the following:

code:
#NameVirtualHost 12.34.56.78:80
#NameVirtualHost 12.34.56.78
#
# VirtualHost example:
# Almost any Apache directive may go into a 
# VirtualHost container.
#
#<VirtualHost ip.address.of.host.some_domain.com>
# ServerAdmin webmaster@host.some_domain.com
# DocumentRoot /www/docs/host.some_domain.com
# ServerName host.some_domain.com
# ErrorLog logs/host.some_domain.com-error_log
# CustomLog logs/host.some_domain.com-access_log common
#</VirtualHost>

#<VirtualHost _default_:*>
#</VirtualHost>

Editing httpd.conf

Now using Notepad or WordPad edit the first line (from the excerpt above) like this:

code:
NameVirtualHost 127.0.0.1:80

Note that 2 changes were made;

  1. I removed the # sign from the start of the line
  2. I edited the IP address to 127.0.0.1

Adding virtual hosts in httpd.conf

Next, edit the following part from the excerpt above

code:
#<VirtualHost ip.address.of.host.some_domain.com>
# ServerAdmin webmaster@host.some_domain.com
# DocumentRoot /www/docs/host.some_domain.com
# ServerName host.some_domain.com
# ErrorLog logs/host.some_domain.com-error_log
# CustomLog logs/host.some_domain.com-access_log common
#</VirtualHost>

to something like this:

code:
<VirtualHost 127.0.0.1>
ServerName www.desilva.biz
ServerAdmin your_email@yourwebserver.com
DocumentRoot "/home/desilva/public_html"
ErrorLog logs/error_log
CustomLog logs/access_log common
# I didn't add the cgi-bin in this example
# but you can, look at the sample 
# for the other site below.
</VirtualHost>

<VirtualHost 127.0.0.1>
ServerName gidhelp.com
ServerAdmin your_email@yourwebserver.com
DocumentRoot "/home/gidhelp/public_html"
ScriptAlias /cgi-bin/ "/home/gidhelp/public_html/cgi-bin/"
  <Directory /home/gidhelp/public_html/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Save the file and when you start Apache the next time, open up your browser and type

code:
http://www.desilva.biz

or

code:
http://gidhelp.com

you will be taken to your virtual website on your Windows ME PC!

Do NOT forget to rename HOSTS.SAM before trying this.

TOP

Do you find it easy to navigate through this site?

 Yes

 No

 Where am I?