You can configure the Web Server to recognize and execute CGI programs.
This section discusses the following topics:
Using the Admin Console:
You can specify a directory that contains only CGI programs. All files are run as programs regardless of the file extensions.
Using the Admin Console:
Select Common Tasks tab > CGI Directories from the Virtual Server Tasks list.
The CGI Directory window is displayed.
The Add CGI Directory window is displayed.
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:
Using the Command-Line Interface (CLI):
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
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:
ObjectType fn="force-type" type="magnus-internal/cgi"
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.
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.
Restart the server after editing mime.types.
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 Administrator’s Guide.