4.7 Creating Virtual Hosts

The term virtual host, sometimes called a virtual server, refers to the practice of running more than one Web site on a single computer (such as www.company1.com and www.company2.com). Virtual hosts can be IP-based, meaning that you have a different IP address for every Web site, or name-based, meaning that you have multiple DNS names assigned to a single IP address. Visitors to the Web sites are unaware that both sites are running on the same physical server.

The Virtual Hosts page in Apache Manager enables you to set up virtual hosts.

Figure 4-5 Apache Virtual Hosts

Virtual Hosts page
  1. Specify the IP address of your server, followed by a colon and the port number you want to use.

    For example:

    
    172.16.5.18:80
    
    

    If you do not include a port number, Apache assumes port 80.

    IMPORTANT:If you are setting up a name-based virtual host and assigning an alternate port number, you must first configure Apache to listen to the port number you assign. See Section 3.8, Managing Listen Ports.

  2. (Optional) To instruct Apache to also listen on a secure port, press the spacebar, then add the same IP address followed by the secure port number. For example: 172.16.5.18:443.

  3. In the Server Name field, type a hostname for your server, such as www.mycompany.com.

  4. Select the Host Type to be used.

    If you are going to use one virtual host per IP/port combination, then you should select IP-based virtual hosting. Otherwise, select name-based virtual hosting.

  5. Click Save > Save to save your changes.

    or

    Click Save > Save and Apply to save your changes and restart Apache so your changes are immediately put into effect.

    For information about where configuration information is stored, see Section 2.3.3, Saving Configuration Changes and Restarting Apache in Apache Manager.

For more information about IP-based virtual hosting, see Apache IP-based Virtual Host Support. For more information about when and how to use name-based virtual hosting, see Name-based Virtual Host Support.