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

ProcedureTo Configure Perl Programs to Execute as CGI Programs

  1. Create a simple Perl program called hello.pl.

    #!<server_root>/lib/perl/perl
    print "Content-type:text/html\n\n";
    print "Hello World!";
  2. Create a directory for this program.

    By convention, this directory is named cgi-bin and is located under the instance configuration directory. For example:


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

  4. In the Admin Console, select the Common Tasks tab.

  5. Select CGI Directories from the Virtual Servers Tasks list.

    The CGI Settings window is displayed.

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

    The Add CGI Directories window is displayed.

  7. Type the Prefix and the CGI directory path.

  8. 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 that you specify must have execute permissions.


  9. Click Save to save the changes.

  10. Access the program from a browser window.

    Open a browser window. For example, your server is called acme, and is running on port 2222, you would type http://acme:2222/cgi-bin/hello.pl.

    This example displays the message “Hello World” in the browser window.