Oct 221998
 

Apache – virtual hosts (continued)

See also Apache topics.

Note: this document was originally written using ml.org as the main domain.  When ml.org disappeared, I started using .cx.  I have since changed all references to ml.org to .cx.  For information on how I did that, see httpd/dns.

Note: I’ve since stopped using freebsddiary.cx for my test examples.  I now use http://test.freebsddiary.org.

Note: I’ve let racingsystem.cx lapse.  I now longer use it.

Virtual servers

Despite my previous attempts at getting virtual websites going, they never worked.   So today I started trying it again.  Here’s what I added to the bottom of: my Apache configuration file (/usr/local/etc/apache/httpd.conf)

<VirtualHost 192.168.0.45>
   DocumentRoot /usr/local/www/data/test.freebsddiary.org
   ServerName test.freebsddiary.org
   ErrorLog /var/log/apache/freebsddiary.org-error.log
   TransferLog /var/log/apache/freebsddiary.org-access.log
</VirtualHost>

<VirtualHost 192.168.0.45>
   DocumentRoot /usr/local/www/data/www.test.freebsddiary.org
   ServerName freebsddiary.yi.org
   ErrorLog /var/log/apache/www.test.freebsddiary.org-error.log
   TransferLog /var/log/apache/www.test.freebsddiary.org-access.log
</VirtualHost>

Where 192.168.0.45 is the IP address of my FreeBSD box.  Then I restarted apache.

Then I browsed to the following two locations:

http://www.test.freebsddiary.org/

http://test.freebsddiary.org/

You will note that the IP address for each of these domains is the same.  That’s the benefit of virtual servers.