You can use the HTTP Configuration Tool to configure virtual hosts. Virtual hosts allow you to run different servers for different IP addresses, different hostnames, or different ports on the same machine. For example, you can run the website for
on the same Web server using virtual hosts. This option corresponds to the
directive for the default virtual host and IP-based virtual hosts. It corresponds to the
directive for a
The directives set for a virtual host apply only to that particular virtual host. If a directive is set server-wide using the Edit Default Settings button and not defined within the virtual host settings, the default setting is used. For example, you can define a Webmaster email address in the Main tab and not define individual email addresses for each virtual host. The HTTP Configuration Tool includes a default virtual host (see Figure 19-8).
Figure 19-8: Virtual hosts
http://httpd.apache.org/docs-2.0/vhosts/ and the Apache HTTP server documentation on your machine provide more information about virtual hosts.
To add a virtual host, click the Virtual Hosts tab and then click the Add button. You can also edit a virtual host by selecting it in the list and clicking the Edit button.
The General Options settings apply only to the virtual host that you are configuring. Set the name of the virtual host in the Virtual Host Name text area. This name is used by the HTTP Configuration Tool to distinguish between virtual hosts.
Set the Document Root Directory value to the directory that contains the root document (such as index.html ) for the virtual host. This option corresponds to the DocumentRoot directive within the VirtualHost directive. Before Red Hat Linux 7, the Apache HTTP server provided with Red Hat Linux used /home/httpd/html as the DocumentRoot . In Red Hat Linux 8.0, however, the default DocumentRoot is /var/www/html .
The Webmaster email address corresponds to the ServerAdmin directive within the VirtualHost directive. This email address is used in the footer of error pages if you choose to show a footer with an email address on the error pages.
In the Host Information section, choose Default Virtual Host, IP-based Virtual Host, or Name-based Virtual Host.
You should configure only one default virtual host (remember that there is one setup by default). The default virtual host settings are used when the
If you choose IP-based Virtual Host, a window appears in which you can configure the VirtualHost directive based on the IP address of the server. Specify this IP address in the IP address field. To specify more than one IP address, separate each IP address with spaces. To specify a port, use the syntax IP Address:Port . Use :* to configure all ports for the IP address. Specify the hostname for the virtual host in the Server Host Name field.
If you choose Name-based Virtual Host, a window appears in which you can configure the NameVirtualHost directive based on the host name of the server. Specify the IP address in the IP address field. To specify more than one IP address, separate each IP address with spaces. To specify a port, use the syntax IP Address:Port . Use :* to configure all ports for the IP address. Specify the host name for the virtual host in the Server Host Name field. In the Aliases section, click Add to add a hostname alias. Adding an alias here adds a ServerAlias directive within the NameVirtualHost directive.
If an Apache HTTP server is not configured with SSL support, communications between an Apache HTTP server and its
Enabling Apache SSL support enables the use of the mod_ssl security module. To enable it through the HTTP Configuration Tool, you must allow access through port 443 under the Main tab > Available Addresses. Refer to the “Basic Settings” section of this chapter for details. Then, select the virtual host name in the Virtual Hosts tab, click the Edit button, choose SSL from the left-hand menu, and check the Enable SSL Support option as shown in Figure 19-9. The SSL Configuration section is preconfigured with the
Figure 19-9: SSL support
You cannot use name-based virtual hosts with SSL, because the SSL handshake (when the browser accepts the secure Web server’s certificate) occurs before the HTTP request that identifies the appropriate name-based virtual host. If you want to use name-based virtual hosts, they will work only with your nonsecure Web server.
You must purchase your own digital certificate. Do not use the dummy one provided in Red Hat Linux for your website. For details on purchasing a CA-approved digital certificate, refer to the section “Apache HTTPD Secure Service Configuration.”
The Site Configuration, Environment Variables, and Directories options for the virtual hosts are the same directives that you set when you clicked the Edit Default Settings button, except the options set here are for the individual virtual hosts that you are configuring. Refer to the “Default Settings” section of this chapter for details on these options.