Installation guide

Chapter 14. Apache HTTP Server 207
The configuration directives for your secure server are contained within virtual host tags in the
/etc/httpd/conf.d/ssl.conf file. If you need to change anything about the configuration of
your secure server, you will need to change the configuration directives inside the virtual host tags.
By default, both the secure and the non-secure Web servers share the same DocumentRoot. To change
the DocumentRoot so that it is no longer shared by both the secure server and the non-secure server,
change one of the DocumentRoot directives. The DocumentRoot either inside or outside of the
virtual host tags in httpd.conf defines the DocumentRoot for the non-secure Web server. The
DocumentRoot within the virtual host tags in conf.d/ssl.conf define the document root for the
secure server.
The secure the Apache HTTP Server server listens on port 443, while your non-secure Web server
listens on port 80. To stop the non-secure Web server from accepting connections find the line which
reads:
Then comment out any line in httpd.conf which reads Listen 80.
14.8.2. Setting Up Virtual Hosts
To create a virtual host, you will need to alter the virtual host lines, provided as an example in
httpd.conf or create your own virtual host section.
The virtual host example lines read as follows:
#
VirtualHost *
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
# /VirtualHost
Uncomment all of the lines, and add the correct information for the virtual host.
In the first line, change * to your server’s IP address. Change the ServerName to a valid DNS name
to use for the virtual host.
You will also need to uncomment one of the NameVirtualHost lines below:
NameVirtualHost *
Next change the IP address to the IP address, and port if necessary, for the virtual host. When finished
it will look similar to the following example:
NameVirtualHost 192.168.1.1:80
If you set up a virtual host and want it to listen on a non-default port, you will need to set up a virtual
host for that port and add a Listen directive for corresponding to that port.
Then add the port number to the first line of the virtual host configuration as in the following example:
VirtualHost ip_address_of_your_server:12331
This line would create a virtual host that listens on port 12331.
You must restart httpd to start a new virtual host. See Section 14.4 for instructions on how to start
and stop httpd.
Comprehensive information about creating and configuring both name-based and IP address-based
virtual hosts is provided on the Web at http://httpd.apache.org/docs-2.0/vhosts/.