Search code examples
perldancer

Perl Dancer initial configuration


I have a fully web site in perl under cgi-bin, but now, at client side, i'll move to MVC all my client stuff.. i decided that would be AJAX heavy with smooth transitions between sections instead of full refreshes.

At this point, there is no problem at all.

First problem, comes that i want to make an fully perl restapi to clarify things and take the fully advantaged of use backbonejs for example.

So, at this point i have somenting like this:

www.foo.com/cgi-bin/home.pl
www.foo.com/cgi-bin/wines.pl

...

After reading a lot, i'm thinking to use Dancer, since seems quite simple and fast.

My main question after all these lines is simple..

Where should i create my project? "Dancer -a App" is it supposed to be created inside cgi-bin?

I'm developing under windows machine, but my host is ubuntu, so, could you guys tell me what is the most common directory?

After hours trying to work with that, nothing.. still unable..

I can run my app as standalone like "perl bin/MyApp.pl" but in deploying nothing..

my httpd.conf

<virtualhost *:80>
   ServerName localhost
    DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/MyApp/public/"
    ServerAdmin admin@localhost

    <directory "C:/Program Files/Apache Group/Apache2/htdocs/MyApp/public/">
       AllowOverride None
       Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
       Order allow,deny
       Allow from all
       AddHandler cgi-script .cgi
    </Directory>

ScriptAlias / C:/Program Files/Apache Group/Apache2/htdocs/MyApp/public/dispatch.cgi/

what am i doing wrong?


Solution

  • I usually stick my Dancer project in ~/src/My-Dancer-Proj

    Then, rather than using cgi, I use fastcgi. My httpd.conf looks like this...

    <VirtualHost *:80>
      ServerName myserver.com
      DocumentRoot /home/my_user/src/My-Dancer-Proj/public
      <Directory "/home/my_user/src/My-Dancer-Proj/public">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
        AddHandler fcgid-script .fcgi
      </Directory>
    
      RewriteEngine On
      RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
      RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /dispatch.fcgi$1 [QSA,L]
    </VirtualHost>