Apache Tips: One Web Server, Multiple Distinct Web Sites
So you have one Apache web server on your Mac OS X, Mac OS X Server, Linux, Unix or OpenVMS (and either as Apache, or in its guise as the Secure Web Server (SWS, and sometimes referred to by its older CSWS nomenclature) on OpenVMS), and you're interested in having that server instantiate multiple web sites. This involves a little DNS configuration work (usually at your ISP), and configuring virtual hosting. And this configuration can be surprisingly confusing to many folks. Here's a quick tour…
The IP Domain Name System (DNS) is involved here only in how the client box finds the target IP address, given the target IP host name. (While it is possible to set up local DNS on Mac OS X Server, your public DNS name(s) for your web server(s) is usually established at your ISP DNS servers.) The IP host name means nothing to IP routing, that's all based on the IP host address. Beyond this initial name-to-address translation (which occurs underneath the web browser on the client), DNS is not involved.
After this initial client-side address translation, DNS is not involved in what happens here.
Once the web browser has the target IP address (retrieved from the client's DNS server), the client then routes the http web traffic to whatever web server is listening on that IP address.
Now here's the part that tends to confuse: the web browser also includes the text-format host name of the target address in the http traffic. And the web server can look at this. And can tell what the intended web site is, from among the various virtual web servers possible within Apache.
Put another way, the IP packet lands on the web server, based on the web server IP address. And based on the contents of the http protocol, the web server can see what the client browser entered. And can serve up a virtual web host.
To configure this environment, use whatever the local tool or interface is to configure virtual web servers. With Mac OS X Server, this is the Server Admin tool that is used to add virtual web servers. With OpenVMS or other command-line platforms, you will be editing the configuration files to add the hosts. And set up DNS CNAME (DNS alias) entries for the host. An example below shows the DNS data for the frobnitz host, with three aliases, and a subsequent entry shows the contents of the httpd.conf configuration file for a virtual host. And with the associated entries for frobnitz, www, secret and public, the same Apache web server can present itself as four apparently-different and apparently-unique web servers.
DNS services
First, assume the frobnitz.example.com host (at 10.1.1.27) and three CNAME alias entries in the local DNS database, or in the DNS database for your DNS provider or ISP (and depending on the desired “horizon” for the particular DNS host name visibility):
frobnitz IN A 10.1.1.27 www IN CNAME frobnitz secret IN CNAME frobnitz public IN CNAME frobnitz
If you're establishing and using DNS on Mac OS X Server, then configure DNS services on your LAN and (if applicable) public DNS.
If you're working on OpenVMS or various other platforms, you'll edit the DNS data (zone) files directly here.
Apache Virtual Hosts
To add the virtual host entries on Mac OS X Server, launch Server Admin, select the server, select Web, select Sites, and add or edit sites from the list by clicking the + at the bottom of the table, or by selecting a site from within the list and making your changes in the information revealed below when the entry is selected. You'll enter the host name, the IP address (usually a wildcard), and the port (usually port 80 for http, or 443 for https). The directory is typically unique for a static web site, though a web content management system (CMS) can see the same directory configured for multiple web sites.
If you're not on Mac OS X Server (and thus lack the Server Admin tool), here are the Apache virtual host entries. You'll want to customize these for your own requirements, local directory structures (and filename formats!) for your platform, web logging and email addresses, and other site-specific details:
<VirtualHost www.example.com *>
ServerAdmin postmaster@example.com
DocumentRoot "/web_storage/www"
ServerName www.example.com
</VirtualHost>
<VirtualHost secret.example.com *>
ServerAdmin postmaster@example.com
DocumentRoot "/web_storage/secret"
ServerName secret.example.com
</VirtualHost>
<VirtualHost public.example.com *>
ServerAdmin postmaster@example.com
DocumentRoot "/web_storage/public"
ServerName public.example.com
</VirtualHost>To manage logging with Apache, use the TransferLog and ErrorLog statements, or configure Apache to use a single log. The typical parallel log file mechanism adds the following to each virtual host entry:
ErrorLog /web_storage/foo_error.log
TransferLog /web_storage/foo_transfer.logOn typical Unix boxes, these log files are often located in some OS-specific variation of /var/log/httpd/ or /var/log/apache2/.
Troubleshooting
On OpenVMS, Apache can be sensitive to the DECC$UNIX_LEVEL logical name used with DEC C and the standard library and the other related logical name mechanisms for the the standard library; it is best to avoid setting this value system wide, or setting this within the context of Apache.
Additional Information
For full details on the Apache web server, see the Apache web site.

Comments
BYTLM
Per ITRC threadId=1465650, OpenVMS can require substantial increases to the BYTLM process quota when adding additional virtual hosts. This increase is needed for the Apache$WWW username created in SYSUAF when the Apache port (also known as HP CSWS and SWS) is installed on OpenVMS.
While looking at this case, I noticed that the VMS Apache port appears to lack the apachectl configtest tool, too. (The analog looks to be the Apache$SPL_DISABLED logical name?)
Wrinkles with Server Admin
Mac OS X Server and its Server Admin tools and the Apache administrative interface allows the configuration of Web Server Aliases, and Wildcard records.
For the aliases, launch Server Admin, select the server, select the web server, select the Site (what Apple calls the virtual host), then select the Aliases; what is listed as Web Server Aliases.
For the wildcard (default) site, you'll want the wildcard entry in the Sites table listed last if you want a default web server presentation, and enabled. If not, disable it or remove it.
Another advise (for SWS a least)
* Remove all hosting data from the main configuration file if you don't need it: The first virtual host will usually be the default one...You can eventually specify which one is considered default.
* Create a configuration file for each site, and include it in the configuration file
I used this scheme when creating my first server (CSWS 1.2) and it proved extremely comfortable when upgrading to 2.1. If you run multiple servers on one box, you can easily move a site from one server to the other.
This works for SWS (Apache on OpenVMS) but I'm sure it holds for other environments as well.
That works...
Yes; this works on other boxes. This general configuration file structure is the default created by Server Admin on Mac OS X.
One other wrinkle: you may need to configure directory aliases or parallel virtual host entries or such, particularly if you're using NAT on the local LAN; to have two different names that land on the same (virtual) web site.