|
The VirtualHost directive in the httpd.conf configuration file is used to set the values of ServerName, DocumentRoot, ErrorLog and TransferLog or CustomLog configuration directives to different values for each virtual host. Multiple websites can be served from one computer, even if they have different hostnames. Each host name that is served from the single computer that hosts them all is referred to as a virtual host. There are two ways provided by Apache for setting up virtual hosts on a single computer, IP based and Name based. IP based virtual hosts use the IP address of the connection to determine the correct virtual host. Hence, a unique IP address is required for each host. With name based virtual hosting, Apache Web server relies on the client to deliver the hostname as part of the HTTP leaders sent to Apache. Using this technique, many different virtual hosts can share the same IP address. Older browsers do not support delivering a hostname with their HTTP headers. This is not part of their HTTP 1.1 header encoding. Hence these browsers will only work with IP based virtual hosts. Apache can be configured to support multiple virtual hosts either by running a separate httpd daemon for each hostname, or by running a single httpd daemon, which supports all the virtual hosts. If separate httpd daemons must be run for each host, separate installations of Apache for each virtual host have to be created. For each installation, use the Listen directive in the httpd.conf configuration file to select which IP address or virtual host that daemon services For example, Listen 192.168.0.1:80. A single http daemon can also be used to service to the main server and all its virtual hosts. Click here to download the complete E-Book.
|