Forum Moderators: phranque
### Section 3: Virtual Hosts
#
# 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 XX.XXX.XXX.XXX
#
# 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 XX.XXX.XXX.XXX:80>
ServerAdmin admin@test1.com
DocumentRoot "C:/Apache2/htdocs/test1"
ServerName www.test1.com
ServerAlias www.test1.com *.test1.com
ErrorLog logs/test1.com-error_log
CustomLog logs/test1.com-access_log common
</VirtualHost>
#
<VirtualHost XX.XXX.XXX.XXX:80>
ServerAdmin admin@test2.com
DocumentRoot "C:/Apache2/htdocs/test2"
ServerName www.test2.com
ServerAlias www.test2.com *.test2.com
ErrorLog logs/test2.com-error_log
CustomLog logs/test2.com-access_log common
</VirtualHost>
[edited by: jdMorgan at 2:47 am (utc) on Mar. 17, 2006]
[edit reason] No code dumps, please. [/edit]
# Please see the documentation at
# [httpd.apache.org...]
# for further details before you try to setup virtual hosts.
Thats what I use.
Remember you need to restart apache before the changed take effect. Always make a backup just incase things get broken.
Another importaint aspect to take into account: If you have the server set up on your local network you may not be able to view the sites using their domain name. Domain name requests are designed to come from the outside world, you need to add an entry to your hosts file in order to be able to view domain sites directly from within your lan.
Mack.