如何在Windows Server 2008的IIS 7上安装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 7 on your Windows Server 2008 system to serve Perl scripts via CGI.

Perl是一种非常流行的脚本语言,可用于开发各种工具。 众所周知的用途之一是基于Web的CGI(通用网关接口)应用程序,该应用程序允许从Web服务器执行Perl脚本。 只需进行一些配置,就可以在Windows Server 2008系统上配置IIS 7,以通过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以使用此目录中的文件。

image

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

image_thumb22

Click on the action, “Add Script Map”.

单击操作“添加脚本映射”。

image

To allow IIS to execute Perl script files (.pl), configure the new script mapping with the following settings:

要允许IIS执行Perl脚本文件(.pl),请使用以下设置配置新的脚本映射:

  • Request path: *.pl

    请求路径:*。pl
  • Executable: C:perlbinperl.exe “%s” %s (where ‘C:perl’ is the location where you extracted the Perl binaries)

    可执行文件:C:perlbinperl.exe“%s”%s(其中“ C:perl”是您提取Perl二进制文件的位置)
  • Name: Perl-pl

    名称:Perl-pl
image

In the Request Restrictions dialog, set the Verbs tab to allow the following: GET,HEAD,POST.

在“请求限制”对话框中,将“动词”选项卡设置为允许以下操作:GET,HEAD,POST。

image

Apply all changes.

应用所有更改。

When creating the new script mapping, IIS will ask you if you want to allow this script mapping to run as a CGI application. Answer ‘Yes’ to the dialog.

创建新的脚本映射时,IIS会询问您是否要允许此脚本映射作为CGI应用程序运行。 在对话框中回答“是”。

image

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

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

  • Request path: *.cgi

    请求路径:*。cgi
  • Executable: C:perlbinperl.exe “%s” %s

    可执行文件:C:perlbinperl.exe“%s”%s
  • Name: Perl-cgi

    名称:Perl-cgi
  • Verbs: GET,HEAD,POST

    动词:GET,HEAD,POST

Once finished apply your changes and select ‘Yes’ when IIS prompts you to confirm running the script mapping as an application.

完成后,应用更改,并在IIS提示您确认将脚本映射作为应用程序运行时选择“是”。

image

Once you have configured IIS to run both file types, they will be listed in your Handler Mappings.

将IIS配置为同时运行这两种文件类型后,它们将在“处理程序映射”中列出。

image

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”命令,以确保更改已通过并处于活动状态。

image_thumb30

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

此时,IIS 7应该能够成功提供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现在已启动并在您的计算机上运行。

image

结论 (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/50479/how-to-install-perl-on-iis-7-for-windows-server-2008/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值