如何在Windows Server 2003的IIS 6上安装Perl

Perl is a very popular scripting language which is used to develop a wide variety of tools. One of it’s well know uses is web based CGI (Common Gateway Interface) applications which allow Perl scripts to be executed from a web server. With a little configuration, you can configure IIS 6 on your Windows Server 2003 system to serve Perl scripts via CGI.

Perl是一种非常流行的脚本语言,可用于开发各种工具。 众所周知的用途之一是基于Web的CGI(通用网关接口)应用程序,该应用程序允许从Web服务器执行Perl脚本。 只需进行一些配置,就可以在Windows Server 2003系统上配置IIS 6,以通过CGI服务Perl脚本。

复制Perl二进制文件 (Copying the Perl Binaries)

Before any IIS setup can be done, the Perl binary files must be extracted to your system. Download the ActiveState Perl distribution package (get the AS zip file and not the installer) and extract them to a folder on your server (i.e. ‘C:perl’). We will map IIS to use the files located in this directory.

在完成任何IIS设置之前,必须将Perl二进制文件提取到系统中。 下载ActiveState Perl分发软件包(获取AS zip文件而不是安装程序),然后将其解压缩到服务器上的文件夹(即“ C:perl”)。 我们将映射IIS以使用此目录中的文件。

如何在Windows Server 2003的IIS 6上安装Perl

配置IIS 6以运行Perl脚本 (Configuring IIS 6 to Run Perl Scripts)

Open Internet Information Services Manager to the Web Service Extensions and select the option to add a new extension.

打开Internet信息服务管理器以访问Web服务扩展,然后选择添加新扩展的选项。

如何在Windows Server 2003的IIS 6上安装Perl

Set the following properties:

设置以下属性:

  • Extension name: Perl CGI

    扩展名:Perl CGI
  • Required files: C:perlbinperl.exe “%s” %s (assuming you extracted the files to ‘C:perl’)

    所需文件:C:perlbinperl.exe“%s”%s(假设您将文件解压缩到“ C:perl”)
  • Status set to allowed

    状态设置为允许

Once finished, apply your changes.

完成后,应用您的更改。

如何在Windows Server 2003的IIS 6上安装Perl

You should see the new extension in the Web Service Extension list with the status set to allowed.

您应该在Web服务扩展列表中看到新的扩展,其状态设置为允许。

如何在Windows Server 2003的IIS 6上安装Perl

With the service extension installed, we have to create the Perl script file type mappings.

安装了服务扩展后,我们必须创建Perl脚本文件类型映射。

Right click on the Web Sites folder and go to the Properties dialog.

右键单击“网站”文件夹,然后转到“属性”对话框。

如何在Windows Server 2003的IIS 6上安装Perl

On the Home Directory tab, open the Configuration dialog.

在“主目录”选项卡上,打开“配置”对话框。

如何在Windows Server 2003的IIS 6上安装Perl

To allow IIS to execute Perl script files (.pl), add an extension mapping with the following properties:

要允许IIS执行Perl脚本文件(.pl),请添加具有以下属性的扩展名映射:

  • Executable: same as the “Required files” entered when creating the “Perl CGI” extension above

    可执行文件:与在上面创建“ Perl CGI”扩展名时输入的“必需文件”相同
  • Extension: .pl

    扩展名:.pl
  • Verbs: GET,HEAD,POST

    动词:GET,HEAD,POST
  • Check the box for script engine

    选中脚本引擎框

Once finished apply your changes.

完成后,应用您的更改。

如何在Windows Server 2003的IIS 6上安装Perl

Additionally, if Perl scripts will be deployed as CGI files (.cgi), an extension mapping will need to be configured for this file type as well:

此外,如果将Perl脚本部署为CGI文件(.cgi),则也需要为此文件类型配置扩展名映射:

  • Executable: same as the “Required files” entered when creating the “Perl CGI” extension above

    可执行文件:与在上面创建“ Perl CGI”扩展名时输入的“必需文件”相同
  • Extension: .cgi

    扩展名:.cgi
  • Verbs: GET,HEAD,POST

    动词:GET,HEAD,POST
  • Check the box for script engine

    选中脚本引擎框

Once finished apply your changes.

完成后,应用您的更改。

如何在Windows Server 2003的IIS 6上安装Perl

After making the required configuration changes to IIS, run the “iisreset” command from the command prompt to ensure the changes are pushed through and active.

对IIS进行所需的配置更改后,从命令提示符处运行“ iisreset”命令,以确保更改已通过并处于活动状态。

如何在Windows Server 2003的IIS 6上安装Perl

At this point, IIS 6 should be able to successfully serve Perl scripts.

此时,IIS 6应该能够成功提供Perl脚本。

测试Perl (Testing Perl)

At this point, your server is ready to go, but just to be sure we can confirm your Perl setup through IIS pretty easily. Create a couple of text files in the directory ‘C:Inetpubwwwroot’ named ‘test.pl’ and ‘test.cgi’ both containing the following:

此时,您的服务器已准备就绪,但是请确保我们可以通过IIS轻松确认您的Perl设置。 在目录“ C:Inetpubwwwroot”中创建几个文本文件,名称分别为“ test.pl”和“ test.cgi”,其中都包含以下内容:

#!c:perlbinperl.exe

#!c:perlbinperl.exe

use strict; use CGI; my $test = new CGI;

使用严格 使用CGI; 我的$ test =新的CGI;

print $test->header(“text/html”),$test->start_html(“Perl Test”); print $test->h1(“Perl is working!”); print $test->end_html;

打印$ test-> header(“ text / html”),$ test-> start_html(“ Perl Test”); 打印$ test-> h1(“ Perl正在运行!”); 打印$ test-> end_html;

Finally, browse to the addresses: ‘http://localhost/test.pl’ and ‘http://localhost/test.cgi’ on your server and you should see a message stating that Perl is working. If the page loads successfully, Perl is now up and running on your machine.

最后,浏览到服务器上的地址:“ http://localhost/test.pl”和“ http://localhost/test.cgi”,您应该看到一条消息,指出Perl正在运行。 如果页面成功加载,则Perl现在已启动并在您的计算机上运行。

如何在Windows Server 2003的IIS 6上安装Perl

结论 (Conclusion)

Once you have Perl up and running on your Windows system, you can deploy or develop your own Perl CGI applications.

一旦在Windows系统上启动并运行了Perl,就可以部署或开发自己的Perl CGI应用程序。

链接 (Links)

Download ActivePerl from ActiveState (AS Zip Package)

从ActiveState下载ActivePerl (AS压缩包)

翻译自: https://www.howtogeek.com/50500/how-to-install-perl-on-iis-6-for-windows-server-2003/