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

Configuring CGI Settings

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

This section discusses the following topics:

This section discusses the following topics:

ProcedureEnabling CGI

  1. Using the Admin Console:

    1. Select Common Tasks tab > CGI Directories from the Virtual Server Tasks list.

      The CGI Settings page is displayed.

    2. Select the CGI as file type Enabled box.

ProcedureSpecifying CGI Directories

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

  1. Using the Admin Console:

    1. Select Common Tasks tab > CGI Directories from the Virtual Server Tasks list.

      The CGI Directory window is displayed.

    2. Click New.

      The Add CGI Directory window is displayed.

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

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

  2. Using the Command-Line Interface (CLI):

    1. You can also specify the CGI directory using the create-cgi-dir command.

      The syntax of the command is as follows:

      create-cgi-dir [--user|-u admin-user] [--password-file|-w admin-pswd-file] [--host|-h admin-host] [--port|-p admin-port] [--no-ssl|-N] [--echo|-e] [--rcfile|-R rcfile] [--no-prompt|-Q] [--verbose|-v] --config|-c name --vs|-s name [--shell-cgi=boolean] --uri-prefix|-r prefix --directory|-d dir


      ./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

Changes to the obj.conf File

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.

ProcedureSpecifying CGI File Extensions

You can associate the file types for CGI programs. That is, you can configure the 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 modifying the MIME types file.

  1. Modify the following line in the mime.types file to specify the desired extensions.

    type=magnus-internal/cgi exts=cgi,exe,bat
  2. 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"
See Also

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 1 Administrator’s Guide.