Problem solve Get help with specific problems with your technologies, process and projects.

Enable CGI programs and Net.Data for your V5R2 HTTP server

This exercise will show you how to enable your server to support dynamically generated Web pages.

This exercise will show you how to enable your server to support dynamically generated Web pages. The following table shows you the HTTP server configuration you will use in this task.

Parameter                        Value
Server name                      PBABASICnn
Server root                        /tcp52dnn/basicConfig
Document root                  /tcp52dnn/basicConfig/ITSOco
IP address                         All
Port                                  8000
The first thing we need to do is to give the server permission to serve CGI programs in a certain directory:

  • Using your Admin browser, select the Manage tab.
  • Select your server PBABASICnn from the Server pull down list.

Always make sure the server you are configuring is your own (PBABASICnn)!

You need to create an alias to the library on the iSeries system that contains the CGI program for Net.Data. This alias is used in the URLs, so the library structure and physical names of directories and files are not revealed to end users of your Web site.

  • Click URL mapping on the left pane. See Figure 1.
  • Click Aliases tab and click Add to add an entry to the table.

Be careful! URL path and directory or file name are case sensitive.

Figure 1

Alias Type                         Pull down for Script Alias
URL path                           /cgi-bin/
Host directory or file         /QSYS.LIB/TCP52LMAST.LIB/DB2WWW.PGM/

Your input to the form should look something like Figure 2.

Figure 2

Click Continue, then OK at the bottom of the form.

Next you need to tell your server that it is allowed to run CGI programs from this directory. One of the ways to do this is to create a new context (container) for this directory in which you will place directives allowing access to the CGI program (DB2WWW.PGM).

  • Click Container Management on the left pane and click Directories tab Under the Directory/Directory Match containers you will see two entries in the table. The first was created automatically when the server was created using the create wizard.

    The root directory / is secured by default. The second entry was also added during the create wizard, and it allows the server to serve the home page, other public Web pages and image files.

  1. Under the Directory/Directory Match containers, click Add to add an entry to the table. Enter:
    This is the physical path of the library containing the CGI programs. In this case it is the program DB2WWW.PGM, which is Net.Data. For security reasons your instructor has moved the DB2WWW.PGM program to this library to support the lab environment. See Figure 3.
  2. Figure 3

  3. Click Continue to save this in the config file. Click OK to get back to the list of forms.

Now we need to tell the server who is allowed to access the CGI programs.

  • Select Directory /QSYS.LIB/TCP52LMAST.LIB/ from the Server area pull down list to identify which directory we want to control access to. See Figure 4.
  • Figure 4

  • Click Security on the left, and click Control Access tab. See Figure 5.
    • Figure 5

      1. Under Control access based on where the request is coming from: pull down for Allow then deny. See Figure 6.
      2. Figure 6

      3. Select Specifically allow and deny access and click Add under Specific allowed client hosts. Enter the following:
        Domain Name or IP Address -- all
        Subnet Mask -- (leave blank)
        (See Figure 7.)

        Figure 7

        This combination will allow all users (whether authenticated or not) to run the CGI programs.

        Click Continue.

        Click Apply, then OK.

      Next you need to tell your server that it is allowed to run CGI programs.

      • Make sure you are still selecting the Directory /QSYS.LIB/TCP52LMAST.LIB/: (See Figure 8.)
      • Figure 8

      • Click Dynamic Content and CGI on the left pane and click General Settings tab. (See Figure 9.)
      • Figure 9

      • Select Enabled from Allow CGI scripts to be run pull down list. (See Figure 10.)
      • Figure 10

      • Click Apply. Click OK.

      Now would be a good time to display the configuration file for your PBABASICnn server. Under Tools on the left pane, select Display Configuration File.

      Note: The important items that are new or changed from the previous configuration have been highlighted in bold.

      HTTP server:    PBABASIC00  
      Selected file:    /tcp52d00/basicConfig/conf/httpd.conf  
      1  # Configuration originally created by Apache Setup Wizard Tue Apr 02 23:37:47 GMT+00:00 2002
      2  Listen *:8000
      3  DocumentRoot /tcp52d00/basicConfig/ITSOco
      4  Options -ExecCGI -FollowSymLinks -SymLinksIfOwnerMatch -Includes -IncludesNoExec -Indexes -MultiViews
      5  ErrorLog logs/basic_error_log
      6  LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
      7  LogFormat "%{Cookie}n "%r" %t" cookie
      8  LogFormat "%{User-agent}i" agent
      9  LogFormat "%{Referer}i -> %U" referer
      10 LogFormat "%h %l %u %t "%r" %>s %b" common
      11 CustomLog logs/access_log combined
      12 BrowserMatch "Mozilla/2" nokeepalive
      13 BrowserMatch "JDK/1.0" force-response-1.0
      14 BrowserMatch "Java/1.0" force-response-1.0
      15 BrowserMatch "RealPlayer 4.0" force-response-1.0
      16 BrowserMatch "MSIE 4.0b2;" nokeepalive force-response-1.0
      17 ScriptAlias /cgi-bin/ /QSYS.LIB/TCP52LMAST.LIB/DB2WWW.PGM/
      18 <Directory />
      19    deny from all
      20 </Directory>
      21 <Directory /tcp52d00/basicConfig/ITSOco>
      22    order Allow,Deny
      23    allow from all
      24 </Directory>
      25 <Directory /QSYS.LIB/TCP52LMAST.LIB/>
      26    Order Allow,Deny
      27    Allow from all
      28    Options +ExecCGI
      29 </Directory> 

      It is a good idea, while you are learning the Apache directives, to keep looking at the changes to the configuration file that the GUI is making each time you click Apply and OK.

      About the author: Brian R. Smith is a senior consulting I/T specialist in the IBM International Technical Support Organization (ITSO) Rochester Center. He is the team leader of the iSeries e-business team at the ITSO Rochester Center. You can reach Brian at

Dig Deeper on Implementation

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.