Sun Java System Web Server 7.0 Developer's Guide

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.