Questions? Search our site or call us at 1-800-722-6004

Configure a Web Server for Perl / CGI Scripting

"CGI" stands for "Common Gateway Interface". CGI is a popular method by which a web server can obtain data from (or send data to) databases, documents, and other programs, and present that data to viewers via the web. More simply, CGI is programming for the web. A CGI can be written in any programming language, but Perl is the most popular.

Running Perl Scripts on your Web Server

Although it does not ship with built-in support for executing Perl scripts, it's easy enough to add Perl support to Internet Information Server.

Once the Perl interpreter is installed, you should be able to place Perl CGI scripts in any scripts directory, such as the default /scripts scripts directory. You can also create a new scripts directory, named cgi-bin for example, by physically creating an empty directory on the hard drive, adding it to the Internet Information Server manager and enabling the Execute attribute (Script attribute in Microsoft IIS 4.x).

Note: For security reasons, you do not want Perl.exe to exist in any directory that can be browsed from other computers. With a script mapping in the registry, you can place the Perl.exe outside of the normal directory structure and avoid such security risks.

Adding Perl Support to your Web Server
  • Make sure your web server is properly installed and functioning
  • Download and install Perl 5 for Windows
  • Configure Perl Script Maps
Microsoft IIS < 3.x; or Personal Web Server for Windows NT (discontinued)

WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Use the Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys and Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT or Windows 2000, you should also update your Emergency Repair Disk (ERD).

Update the registry as follows:

  • Start regedt32.exe and Open HKEY_LOCAL_MACHINE\ SYSTEM\CurrentControlSet\ Services\W3SVC\Parameters\ ScriptMap
  • Select "Add Value" from the "Edit" menu.
  • Set "Value Name" to .pl (or .cgi if you plan to name your scipts with a .cgi extention)
  • Set "Data type" to REG_SZ
  • Set "String value" to: \perl.exe %s %s: for example, if you installed Perl in C:\PERL, typec:\perl\bin\perl.exe %s %s
Internet Information Server 4.x
  • Open "Internet Service Manager" for Microsoft IIS 4.x
  • Right click on the web server entry under the "Internet Information Server" folder and select "Properties"
  • Restart all Internet Information Server services and/or restart the server machine.

Note: This will map the .pl file extension to the Perl interpreter on all directories under the selected web server. To enable Perl scripts on just a single virtual directory, select that directory instead and go to its "Properties". 
Select "WWW Service" under "Master Properties" and click on "Edit...
Change to the "Home Directory" tab Click on "Configuration..." Select ".pl" entry (or add one) and click on "Edit" Set "Executable" parameter to: \perl.exe %s %s

For example, if you installed Perl in C:\PERL, type c:\perl\bin\perl.exe %s %s Apply changes and close "Internet Service Manager"

Personal Web Server Running on Windows 95/98

WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Use the Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys and Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT or Windows 2000, you should also update your Emergency Repair Disk (ERD).

  1. On the Start menu, click Run.
  2. In the Open box, type Regedit and click OK.
  3. Open HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC \Parameters\ScriptMap
  4. On the Edit menu, point to New, and click String Value.
  5. Name the value .pl and press ENTER.
  6. Select .pl, and click Modify on the Edit menu.
  7. In the Value Data box, type <the full path to perl.exe>\perl.exe %s %s 
    NOTE: The "%s %s" is case sensitive (for example, "%S %S" will not work).
  8. Close the Registry Editor, and restart your computer.

NOTE: Some versions of PERL automatically add this registry key when you install.

Create a file with Notepad, and type the following lines of code. Save the file as testing.pl in a folder in your web. Make sure this folder is marked executable.

In Notepad, type the following:

   print "HTTP/1.0 200 OK\n";
   print "Content-Type: text/html\n\n";
 
   print "<HTML>\n";
   print "<HEAD>\n";
   print "<TITLE>Perl Test Page</TITLE>\n";
   print "</HEAD>\n";
   print "<BODY>\n";
   print "<H3>This is a test to see if Perl is Working</H3>\n";
   print "<P>\n";
   print "<H5>If you can see this, Perl is properly configured</H5>\n";
   print "</BODY>\n";
   print "</HTML>\n";              
How to Test the Script

To test the script, browse to the Perl script in Internet Explorer. For example, if you placed the testing.pl file in a folder named cgi-bin in your root web, you would type the following in the Internet Explorer address bar:

http://localhost/cgi-bin/testing.pl

The third-party products discussed in this article are manufactured by vendors independent of Taltech; we make no warranty, implied or otherwise, regarding these products' performance or reliability.


Categories: General Product Support, Programmer Guides, Perl/CGI Scripting, Barcode ActiveX

Last Updated: 2011.07.07

Need more help?

Don't hesitate to call or email us with your questions

Our office is open 9AM - 5PM Monday Through Friday (E.S.T.)

Technical Support: 215-496-0202

Toll-Free: 1 (800) 722-6004
Skype: taltech1 (Voice only)
Email: support@TALtech.com