Installing Perl Dancer on Windows with IIS

Dancer is a popular open source web application framework written in Perl and inspired by Ruby’s Sinatra. Here is a simple step-by-step guide to install Perl Dancer on IIS for production use.


Environment installation

First we need to configure our Windows server to run Java Servlet applications. This is easily doable using following instructions.

  1. Download and install Web Platform Installer.
  2. Run Web Platform Installer and click “Options”.
  3. Add Helicon Zoo feed into “Display additional scenarios” box:  http://www.helicontech.com/zoo/feed. New “Zoo” tab will appear.
  4. Go to the Zoo -> Packages and install Perl Hosting Package.
  5. Accept licenses to start installation process.

SNAGHTML4c01b6

After installation is completed your server is ready to run Perl applications using either FastCGI or Plack/PSGI protocol. Perl Hosting Package includes Strawberry Perl and some other modules, like CPAN Minus, etc.

Creating Perl Dancer web site

For the beginning create a new web site or application in IIS Manager. Either IIS or IIS Express are supported. Let’s name this site “dancer” and folder for it will be “C:\intepub\dancer\”. Now navigate to this folder using command line and run following commands in it:

cpanm -n -L .\perl Dancer

Installation process may take time and after it we will have Dancer compiled and installed with all dependencies in the “C:\intepub\dancer\perl” folder. Local installation is preferable as when you’ll need to deploy your application to the production server your site will have no dependencies, except for Perl Hosting Package from Helicon Zoo.

Now let’s create new Dancer application and call it “mysite”. This is done with the following two commands in the same location:

set PERL5LIB=.\perl\lib\perl5\
perl\bin\dancer.bat -a mysite

 

After site is created we need to provide write permissions to the  “C:\intepub\dancer\mysite\logs\” folder. Dancer requires this permissions to run. Since we already have command line open in the right location, let’s use Windows “icacls” tool for it. Run the following two commands:

md mysite\logs\
icacls mysite\logs\ /t /grant:r "IIS_IUSRS:M"

 

As the last step we need to create web.config file in the root of the web site – “C:\intepub\dancer\web.config”. Put this code into the web.config file to activate Helicon Zoo for this location:

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

      <application name="dancer">
        <environmentVariables>
          <add name="APP_WORKER" value="%APPL_VIRTUAL_PATH%mysite\bin\app.pl" />
          <add name="PERL5LIB" value="%APPL_PHYSICAL_PATH%\perl\lib\perl5" />

        </environmentVariables>
      </application>

    </heliconZoo>

    <handlers>
      <add name="dancer#x86" scriptProcessor="perl.5.12.psgi" path="*" verb="*" modules="HeliconZoo_x86"
           preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="dancer#x64" scriptProcessor="perl.5.12.psgi" path="*" verb="*" modules="HeliconZoo_x64"
           preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />
    </handlers>

  </system.webServer>
</configuration>

 

A little portion of magic and we have it all set. Just point your browser to the web site created and you should see a Dancer welcome page:

SNAGHTML69f1a0

This entry was posted in Helicon Zoo and tagged . Bookmark the permalink.

2 Responses to Installing Perl Dancer on Windows with IIS

  1. Ben Chiu says:

    Hi: Thanks for the tutorial. I’m trying to install Dancer on a Win2k box, so web platform installer won’t run. I’m attempting to install it manually, but am running into the following error when I try to run anything for Dancer:

    core – session – session_dir /tmp/dancer-sessions cannot be created at c:/Perl/site/lib/Dancer/Session.pm line 16
    BEGIN failed–compilation aborted

    I’m guessing it’s a permissions problem. Any idea where /tmp/dancer-sessions is trying to be created?

    Thanks for any insights.

    Best!

    • Slov says:

      Windows 2000 is not supported by Helicon Zoo, sorry. Try asking your question on Perl Dancer support.