This document describes a logical server-side directory structure for hosting a large number of internet sites, and explains how to correctly configure virtual hosting in Apache HTTPd server with ModPerl.
Apache HTTPd is ideally suited to hosting multiple internet sites from a given server, and we use it on production Unix environments, each hosting hundreds of sites.
§ Directory structure
We use a logical directory structure that scales very well in our hosting environments, doesn't sacrifice simplicity, and makes site-specific backups (and restores) very easy. In this example, we'll use the RFC-compliant internet domain name "example.com" (RFC 2606, section 3) for the internet site.
The "root" of the internet site structure is all self-contained within the "/internet/" directory. Some system administrators may prefer to store this under "/usr/internet/" but for the purposes of this instructional document we won't be doing this.
Initially, the "/internet/" path must be created. Then, for each internet domain name, using the period as a delimiter to separate it into pieces, create the sub-directories in reverse order. For example, "example.com" yields a relative path of "com/example/" (for "lumbercartel.bc.ca" the relative path would be "ca/bc/lumbercartel/").
So, to host "example.com" like we do, the following directories will need to be created:
§ VirtualHost stanzas
Even if you're only needing to host a single web site, we highly recommend using a VirtualHost stanza (a.k.a., "container" or "section") because one of the advantages is that server-specific errors, which are included in the main web server error logs, will not be included in your web server's error logs.
Create the following file, which we will refer to as your "virtual host configuration file:"
Then, add the following content to that newly created configuration file:
If the "cronolog" utility is not installed on your system (we highly recommend that you get it because it's very helpful), change the "CustomLog" and "ErrorLog" directives in the virtual host configuration file that you just created to the following:
In some environments your web server daemon might fail to find "cronolog" during automatic startup during boot. If this happens to you (one of the signs is that Apache HTTPd failed to start with an undefined error), it can be resolved easily by either creating a symbolic link in the "/sbin/" directory (on Unix) to cronolog (we prefer this approach), or by specifying the entire path to cronolog within the configuration file.
§ Include directive
Add the following to the end of your main Apache HTTPd configuration file (which is also called "httpd.conf" and may be stored in "/etc/httpd.conf"):
The "NameVirtualHost" directive won't be needed if the web site doesn't have a dedicated IP address (there are many good reasons that each web site should have a dedicated IP address, such as bandwidth tracking, HTTPS, etc., but further discussion on these points is beyond the scope of this document).
Home | Contact us
Copyright © Inter-Corporate Computer & Network Services, Inc. All rights reserved.
All trademarks are the property of their respective owners.