Web Server 7.0 bundles a Perl interpreter to run CGI programs that are written in the Perl programming language. The Perl interpreter is located at install-dir/lib/perl.
On Windows platform, file associations need to be in place for CGI programs to run. Files with a .pl filename extension need to be associated with the Perl interpreter executable before they can be executed as CGI programs. To create an association for Perl programs to run as CGI programs, perform the following steps:
In a command-line window, type the following commands:.
C:\>assoc .pl=perl C:\>ftype perl="c:\WS7\lib\perl\perl.exe" "%1"
You cannot run CGIs using Perl 5.6.x with the -w flag. Instead, include the following code in the Perl script:
This section describes the steps to configure the server to execute Perl programs as CGI programs.
Create a simple Perl program called hello.pl.
#!<server_root>/lib/perl/perl print "Content-type:text/html\n\n"; print "Hello World!";
Create a directory for this program.
By convention, this directory is named cgi-bin and is located under the instance configuration directory. For example:
Copy the hello.pl file into the /var/opt/SUNWwbsvr7/cgi-bin directory.
In the Admin Console, select the Common Tasks tab.
Select CGI Directories from the Virtual Servers Tasks list.
The CGI Settings window is displayed.
Click the New button in the CGI Directories section.
The Add CGI Directories window is displayed.
Type the Prefix and the CGI directory path.
Choose whether the program is a CGI or a ShellCGI program.
On UNIX platforms:
CGI Directory: /var/opt/SUNWwbsvr7/cgi-bin
On Windows platforms:
CGI Directory: c:\sun\webserver7\cgi-bin
The CGI directory that you specify must have execute permissions.
Click Save to save the changes.
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.