Virtual Hosting Setup

Using vaddhost to Automatically Configure Virtual Subhosts
For each Virtual Subhost you would like to add on Virtual Server, you will need to add what is known as a "VirtualHost" entry in your main web service configuration file (httpd.conf). You can manually configure your virtual subhost or you can use the utility "vaddhost".

The vaddhost utility functions similarly to the "vadduser" utility (which adds new E-mail/FTP accounts to your Virtual Server). The vaddhost utility will ask you several questions about the configuration of your Virtual Subhost and provide you with default responses. As you answer each question, vaddhost will display the VirtualHost definition with each new piece of information. Once you have responded to all questions, vaddhost will create necessary directories and add the VirtualHost entry to your main web server configuration file (httpd.conf). An outline of all the vaddhost steps and an accompanying explanation is included below.

  • Launch vaddhost
    Connect to your Virtual Server using Telnet or SSH and run the vaddhost command by typing:

    % vaddhost
    

    Step 1: Virtual Host Name(s)
    Virtual Host Names identify which domain names will be associated with the Virtual Subhost definition that vaddhost will add to your httpd.conf file. You may specify one or more domain names with each Virtual Subhost definition. Typically, a Virtual Subhosted domain name will at the very least include the "www.domain.name" and "domain.name" Virtual Host Names.

    Step 2: Virtual Host Admin E-mail Address
    The Host Admin E-mail Address identifies the e-mail address of the person responsible for the web site of the subhosted account. If the e-mail address you specify will be a E-mail account on the Virtual Server, you will need to use the vadduser program to add the e-mail account separately.

    Step 3: Virtual Host Document Root
    The Virtual Host Document Root is the directory where the web site content for the Virtual Subhost will be stored. The value of the Document Root is defined with respect to your home directory, so you need not preface your definition with "/usr/home/[your login id]". The default value for the Document Root directory is located in your "vhosts" directory. This is to insure compatibility with the latest version of Microsoft FrontPage should you decide to install Microsoft FrontPage at a later date.

    Step 4: Transfer and Error Log Files
    You can (if you choose) specify separate transfer and error log files for each Virtual Host. This is an optional feature. If you do not wish to store separate logfiles for the Virtual Subhost, the transfer and error log information will be stored in the web server's master log files. If you do wish to store separate tranfer and error log files, vaddhost will provide you with several options based on the input you provided for the Virtual Subhost Document Root.

    Step 5: cgi-bin Directory
    You can also (if you choose) configure a cgi-bin directory for your Virtual Host. This is an optional feature. The cgi-bin "ScriptAlias" directive defines where CGI scripts are stored for the Virtual Subhost. It is important to understand that giving cgi-bin access to your Virtual Subhosted clients is a potential security risk. This is because the CGIs your customers upload and execute have all of the rights and privileges of the CGIs you execute. See our document, Virtual Subhosting security issues for more information.

After you have completed these steps, vaddhost will create all necessary directories and add the VirtualHost entry to your main web server configuration file (httpd.conf) and create a backup of your old httpd.conf file in your ~/www/conf directory. You can remove these backup files at your discretion.

Manually Configuring Virtual Subhosts
For each Virtual Subhost you configure on your Virtual Server you will need to create a new directory for the subhosted domain files and make an addition your web server configuration file. It is probably best to create the new subhosted domain directory in your Virtual Server ~/www/vhosts directory, like this:

  • (if the vhosts directory does not already exist, do this first)
    % mkdir ~/usr/local/etc/httpd/vhosts

    (then make the subhosted domain name directory)
    % mkdir ~/usr/local/etc/httpd/vhosts/newdom

NOTE: It was previously documented that the subhosted domain directory be created in the ~/www/htdocs directory (not the ~/www/vhosts directory). To insure compatibility with the lastest version of Microsoft FrontPage, we recommend that the subhosted domain directories not exist inside the ~/www/htdocs directory.

If you decide to use the vhosts directory for your subhosts (as recommended) and your Virtual Server was setup prior to July 1, 1999, it is likely that a Directory definition will need to be created at the bottom of your ~/www/conf/httpd.conf file (or at the bottom of your ~/www/conf/access.conf file if you have three separate config files). The Directory definition you may need to add is as follows:

<Directory /usr/local/etc/httpd/vhosts>
Options Indexes FollowSymLinks Includes
AllowOverride All
order allow,deny
allow from all
</Directory>

After you have created the directory where the content for the subhosted domain name will reside, open up your httpd.conf file (in your ~/www/conf directory) and add the following lines in the VirtualHost section of the httpd.conf configuration file.

NOTE: Make sure you add the VirtualHost definitions in the correct place in your httpd.conf file. If the VirtualHost definitions are not placed in the VirtualHost section of the httpd.conf file, then you may encounter some compatibility problems with the latest version of Microsoft FrontPage. If your Virtual Server was setup with a single config file, the VirtualHost section of the httpd.conf file is found in the middle of the file. If your Virtual Server was setup with triple config files (httpd.conf, srm.conf, and access.conf), then the VirtualHost section is found at the bottom of the httpd.conf file.
  • (add the following lines to your httpd.conf)
    # point www.newdom.org and newdom.org to subdirectory newdom
    <VirtualHost www.newdom.org newdom.org>
    ServerName www.newdom.org
    ServerAdmin webmaster@newdom.org
    DocumentRoot /usr/local/etc/httpd/vhosts/newdom
    </VirtualHost>

NOTE: It is important that the first domain name you list in the VirtualHost... directive matches the domain name you specify as the ServerName. This will insure that problems do not occur if you install the latest version of Microsoft FrontPage at a later date.

You will need to 1) substitute the subhosted domain name in the place of the newdom.org occurrences in the example above; and 2) replace the name of the subdirectory you choose for the subhosted domain name in the place of newdom above. After you have completed these simple steps, web requests for the subhosted domain name will be directed to the directory you designated and web content will be served from that directory.

You may also want to offer FTP access and Mail accounts for your Virtual Subhosts by using the vadduser command or by using the iManager web-based vadduser utility. When prompted for the "home" directory for the FTP account, you will want to specify the same value that you use for the DocumentRoot definition. This will allow your subhosted client to publish web content to the directory which the web server recognizes as the home directory for the subhosted domain name.

Modifying your httpd.conf file for htdocs Virtual Subhosts

For each domain that you would like hosted on a virtual server, open up your httpd.conf file (in the ~/www/conf directory) and add the following at the appropriate place in the file:

# point newdom.com to subdirectory newdom
<VirtualHost newdom.com>
ServerName www.newdom.com
ServerAdmin webmaster@newdom.com
DocumentRoot /usr/local/etc/httpd/htdocs/newdom
</VirtualHost>

# point www.newdom.com to subdirectory newdom
<VirtualHost www.newdom.com>
ServerName www.newdom.com
ServerAdmin webmaster@newdom.com
DocumentRoot /usr/local/etc/httpd/htdocs/newdom
</VirtualHost>

of course, you would substitute your virtual host domain name and subdirectory in the place of the newdom occurrences.


There are some limitations to Virtual Hosting.

  • There are some limitations to the e-mail capability of subhosts, namely how the Virtual Server intreprets e-mail addresses. For instance, if you send an e-mail to "john@abc.com" and "john@xyz.com" the Virtual Server will view these as the same address. This is because to the Virtual Server, "john@abc.com" and "john@xyz.com" both resolve to "john@192.41.5.2" because both domain names resolve to the same IP address. However a way to get around this limitation by using a utility titled "virtmaps". You can find out more information about "virtmap" setup in the in the Virtual Email Address Mapping Section.

There are some great advantages of Virtual Hosting other than what we have outlined above. Many of your potential virtual host clientel will want cgi-bin access.... this can easily be configured for a virtual host. Please see Advanced Virtual Hosting Configurations

You can offer ftp access and POP accounts for your virtual hosts by using the vadduser command (only available on the Deluxe Virtual Servers).


Copyright © 1996-2000, Last Modified: 21 January 2000A Little Technology Shoppe, LLC (ALTS.NET)®. All rights reserved. All brand names and product names used on these web pages are trademarks, or trade names of their respective holders.