JKL Toy Company creates virtual hosts on HTTP Server (powered by Apache)

This scenario discusses how to create virtual hosts.

Important: Information for this topic supports the latest PTF levels for HTTP Server for i5/OS . It is recommended that you install the latest PTFs to upgrade to the latest level of the HTTP Server for i5/OS. Some of the topics documented here are not available prior to this update. See http://www.ibm.com/servers/eserver/iseries/software/http/services/service.htm Link outside Information Center for more information.

Scenario

The JKL Toy Company (a fictitious company) wants to serve two domain names from one IP address. This can be done using virtual hosts.

The JKL Web administrator has decided to use the name-based virtual host for HTTP Server (powered by Apache) JKLTEST. The ISP has configured the Domain Name Server to route requests for JKLINFO to IP address 9.5.61.228, port 78.

Prerequisites

Start the IBM® Web Administration for i5/OS™ interface

Note: Enter your Webmaster user profile username and password when prompted.
  1. Start a Web browser.
  2. Enter http://[iSeries_hostname]:2001 in the location or URL field .

    Example: http://jkl_server:2001

    Note: If you have changed your port number for the IBM Web Administration for i5/OS interface, replace port 2001 with your port number.
  3. Click IBM HTTP Server for iSeries.
Note: If the IBM Web Administration for i5/OS interface does not start, see Install and test the HTTP Server.

Set up a name-based virtual host

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select your HTTP Server (powered by Apache) from the Server list.

    Example: JKLTEST

  4. Select Global configuration from the Server area list.
  5. Expand Server Properties.
  6. Click Virtual Hosts.
  7. Click the Name-based tab in the form.
  8. Click Add under the Named virtual hosts table.
  9. Select or enter an IP address in the IP address column.
    Example: 9.5.61.228
    Note: The IP address 9.5.61.288 used in this scenario is associated with JKL Toy Company's iSeries™ hostname JKLINFO and registered by a Domain Name Server (DNS). You will need to choose a different IP address and hostname. The IBM Web Administration for i5/OS interface provides the IP addresses used by your iSeries system in the IP Address list; however, you will need to provide the hostname associated with the address you choose.
  10. Enter a port number in the Port column.

    Example: 78

  11. Click Add under the Virtual host containers table in the Named host column.
  12. Enter the fully qualified server hostname for the virtual host in the Server name column.

    Example: JKLINFO.com

    Note: Make sure the server hostname you enter is fully qualified and associated with the IP address you selected.
  13. Enter a document root for the virtual host index file or welcome file in the Document root column.

    Example: /www/jkltest/companyinfo/

    Note: You are specifying a document root using a directory that will be added below in the Set up the virtual host directories section.
  14. Click Continue.
  15. Click OK.

Set up Listen directive for virtual host

  1. Expand Server Properties.
  2. Click General Server Configuration.
  3. Click the General Settings tab in the form.
  4. Click Add under the Server IP addresses and ports to listen on table.
  5. Select the IP address you entered for the virtual host in the IP address column.

    Example: 9.5.61.288

  6. Enter the port number you entered for the virtual host in the Port column.

    Example: 78

  7. Accept Disabled default for FRCA.
  8. Click Continue.
  9. Accept the default values for the remainder of the form.
  10. Click OK.

Set up the virtual host directories

  1. Select the virtual host from the Server area list.
  2. Expand HTTP Tasks and Wizards.
  3. Click Add a Directory to the Web.
  4. Click Next.
  5. Select Static web pages and files.
  6. Click Next.
  7. Enter a directory name for the virtual host in the Name field.

    Example: /www/jkltest/companyinfo/

  8. Click Next.
  9. Enter an alias for the virtual host in the Alias field.

    Example: /companyinfo/

  10. Click Next.
  11. Click Finish.

The document root and directory for the virtual host has been created.

Restart your HTTP Server (powered by Apache)

Select one of the following methods below:

Manage one server

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select your HTTP Server from the Server list.
  4. Click the Stop icon if the server is running.
  5. Click the Start icon.

Manage all servers

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select All Servers from the Server list.
  4. Click the All HTTP Servers tab.
  5. Select your HTTP Server name in the table.

    Example: JKLTEST

  6. Click Stop if the server is running.
  7. Click Start.
Note: If your HTTP Server (powered by Apache) does not start, see Troubleshoot.

Test your HTTP Server (powered by Apache)

  1. Start a new Web browser.
  2. Enter http://[virtual_hostname_name]:[port] in the location or URL field.

    Example: http://JKLINFO:78

View your HTTP Server (powered by Apache) configuration

Your configuration will look similar if you used the given example in this and previous examples.

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select your HTTP Server (powered by Apache) from the Server list.

    Example: JKLTEST

  4. Expand Tools.
  5. Click Display Configuration File.
Listen *:1975
Listen 9.5.61.228:78
DocumentRoot /www/jkltest/htdocs
ServerRoot /www/jkltest
Options -ExecCGI -FollowSymLinks -SymLinksIfOwnerMatch -Includes -IncludesNoExec -Indexes -MultiViews
NameVirtualHost 9.5.61.228:78
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{Cookie}n \"%r\" %t" cookie
LogFormat "%{User-agent}i" agent
LogFormat "%{Referer}i -> %U" referer
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log combined
SetEnvIf "User-Agent" "Mozilla/2" nokeepalive
SetEnvIf "User-Agent" "JDK/1\.0" force-response-1.0
SetEnvIf "User-Agent" "Java/1\.0" force-response-1.0
SetEnvIf "User-Agent" "RealPlayer 4\.0" force-response-1.0
SetEnvIf "User-Agent" "MSIE 4\.0b2;" nokeepalive
SetEnvIf "User-Agent" "MSIE 4\.0b2;" force-response-1.0
<Directory />
	Order Deny,Allow
	Deny From all
</Directory>
<Directory /www/jkltest/htdocs>
	Order Allow,Deny
	Allow From all
</Directory>
<VirtualHost 9.5.61.228:78>
	ServerName JKLINFO.com
	DocumentRoot /www/jkltest/companyinfo/
	<Directory /www/jkltest/companyinfo>
		Order Allow,Deny
		Allow From all
	</Directory>
	Alias /companyinfo/ /www/jkltest/companyinfo/
</VirtualHost>