Sun Java System Web Server 7.0 Update 3 Developer's Guide

Configuring CGI Settings

You can configure the Web Server to recognize and execute CGI programs.

For each CGI directory, the file obj.conf contains a NameTrans directive that associates the name cgi with each request for a resource in that directory. These directives are automatically added to obj.conf when you specify CGI directories.

For example, the following instruction interprets all requests for resources in http://server-name/cgi-local as requests to invoke CGI programs in the directory C:/Sun/Servers/docs/mycgi:

NameTrans fn="pfx2dir" from="/cgi-local" dir="C:/Sun/Servers/docs/mycgi" name="cgi"

The obj.conf file must contain the following named object:

<Object name="cgi">

ObjectType fn="force-type" type="magnus-internal/cgi"

Service fn="send-cgi"


Note –

Do not remove this object from obj.conf. If you do, the server will not recognize CGI directories, regardless of whether you specify them in the Administration Console or manually add more NameTrans directives to obj.conf.

ProcedureTo Enable CGI

  1. In the Admin Console, Select Common Tasks tab.

  2. Select CGI Directories from the Virtual Server Tasks list.

    The CGI Settings page is displayed.

  3. Select the CGI as file type Enabled option.

ProcedureTo Specify CGI Directories

You can specify a directory that contains only CGI programs. All files are run as programs regardless of the file extensions.

  1. In the Admin Console, Select the Common Tasks tab.

    1. >

  2. Select CGI Directories from the Virtual Server Tasks list.

    The CGI Directory window is displayed.

  3. Click New.

    The Add CGI Directory window is displayed.

  4. Specify the URI and path where the CGI programs are stored.

    For example, if you type cgi-bin as the URL prefix, then all URLs to these CGI programs have the following structure:

Example 3–1 Using the create-cgi-dir command

To specify the CGI directory by using the create-cgi-dir command:

./wadm create-cgi-dir --user=admin --password-file=admin.pwd --host=serverhost --port=8989 --config=config1 --vs=config1_vs_1 --uri-prefix=/config1_urlprefix --directory=/cgi-dir

Specifying CGI File Extensions

You can configure CGI programs to have the file extensions .cgi, .exe, or .bat. The programs can be located in any directory in or under the document root directory of the virtual server.

By default, the file extensions for CGI programs are .cgi, .exe, and .bat. However, you can change which extensions indicate CGI programs by the following line in the MIME types file:

type=magnus-internal/cgi exts=cgi,exe,bat

Restart the server after editing mime.types.

When the server is enabled to treat all files with an appropriate extensions as CGI programs, the obj.conf file contains the following Service directive:

Service fn="send-cgi" type="magnus-internal/cgi"

For more information on configuring CGI for your server, see the Configuring CGI Subsystem for Your Server in Sun Java System Web Server 7.0 Update 3 Administrator’s Guide.