Sun Java System Web Server 7.0 Developer's Guide

ProcedureTo Configure Perl Programs to Execute as CGI Programs

  1. Create a simple Perl program called

    1. Use a text editor to create a file called and copy the following lines into it:

      print "Content-type:text/html\n\n";
      print "Hello World!";
  2. Create a directory for this program. By convention, this directory is named as the cgi-bin directory though you can name it whatever you like.

    It is recommended that you create the cgi-bin directory under the instance configuration directory. For example:

    mkdir /var/opt/SUNWwbsvr7/cgi-bin
  3. Copy the file into the /var/opt/SUNWwbsvr7/cgi-bin directory.

  4. Select Common Tasks tab > CGI Directories from the Virtual Servers Tasks list.

    The CGI Settings window is displayed.

  5. Click the New button in the CGI Directories section.

    The Add CGI Directories window is displayed.

  6. Enter the Prefix and the CGI Directory path. Choose whether the program is a CGI or a ShellCGI program.

    For example (On UNIX platforms):

    Prefix: /cgi-bin

    CGI Directory: /var/opt/SUNWwbsvr7/cgi-bin

    On Windows platforms:

    Prefix: \cgi-bin

    CGI Directory: c:\sun\webserver7\cgi-bin

    Note –

    The CGI directory you specified must have execute permissions.

  7. Click Save to save the changes. Access the program from a browser window.

    Open a browser window. If your server is called acme, running on port 2222), type http://acme:2222/cgi-bin/

    Displays the message “Hello World” on the browser window.