Perl FastCGI

Installation

  1. Open Web Platform Installer and install "Perl project":
    Perl installation
  2. Open project's home page and follow steps in "CGI" section:
    Perl installation
    Helicon Zoo will run Perl CGI script as FastCGI, i.e. without restarting or reloading script for every request.

  3. Create an example index.pl file in the root of web site with the following content.
print "Content-type: text/html\r\n\r\n";
print <<EndOfHTML;

<html><head><title>Perl Environment Variables</title></head>
<body> <h1>Hello from Perl!</h1>
<h2>Perl CGI Environment Variables</h2>
<pre><code>
EndOfHTML
foreach $key (sort(keys %ENV))
{
  print "$key : $ENV{$key}\n";
}
print "</code></pre></body></html>";

Output of example perl CGI application:

Perl installation

Deployment

To deploy Perl FastCGI application you will need to install Perl Hosting Package on a target server. Then just copy IIS web site from one machine to another.

web.config example

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>

    <heliconZoo>
      <application name="perl.project" >
        <environmentVariables>

          <!-- Use this APP_WORKER with PSGI engine -->
          <add name="APP_WORKER" value="app.pl" />

          <!--
          Deploy file includes the most common commands required to prepare application before launch (bundle install, migrations etc.)
          It is also possible to specify here any script which evenually will be run by rubyw.exe.
          -->
          <add name="DEPLOY_FILE" value="deploy.pl" />

          <!-- security rules for console are placed in /console/web.config -->
          <add name="CONSOLE_URL" value="console" />

        </environmentVariables>
      </application>
     </heliconZoo>

    <handlers>
      <!-- All transports below support any Psgi-based application. Uncomment the one you wish to use. -->


      <!-- Perl CGI over FastCGI -->
      <add name="perl.project#x86" scriptProcessor="perl.5.12.pipe" path="*.pl" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="perl.project#x64" scriptProcessor="perl.5.12.pipe" path="*.pl" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />

    </handlers>


    <!-- URL Rewrite rules to pass static files, limit console access, etc. -->
    <rewrite>
      <rules>

        <!-- This rule shows welcome page when no Rack application exist. -->
        <rule name="Rewrite to Zoo index if that's an empty application" stopProcessing="true">
          <match url="^/?$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
            <add input="{APPL_PHYSICAL_PATH}" pattern="(.*)" ignoreCase="false" />
            <add input="{C:1}app.pl" matchType="IsFile" negate="true" />
          </conditions>

          <action type="Rewrite" url="public/zoo-index.html" />
        </rule>

      </rules>
    </rewrite>

  </system.webServer>
</configuration>