Perl – Helicon Tech Blog http://www.helicontech.com/articles Web Server Enhancements Mon, 18 Jun 2012 10:21:06 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.4 Installing Perl Dancer on Windows with IIS http://www.helicontech.com/articles/installing-perl-dancer-on-windows-with-iis/ http://www.helicontech.com/articles/installing-perl-dancer-on-windows-with-iis/#comments Tue, 15 May 2012 14:21:56 +0000 http://www.helicontech.com/articles/?p=1013 Continue reading ]]> 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

]]>
http://www.helicontech.com/articles/installing-perl-dancer-on-windows-with-iis/feed/ 2