Dancer
Dancer copied to clipboard
Deployment under CGI on Apache2 doesn't work
Given the script foo.cgi
:
#!/usr/bin/env perl
use strict;
use warnings;
use Dancer;
use Data::Dumper 'Dumper';
set serializer => 'JSON';
post '/foo' => sub {
Dumper(params->{payload});
};
dance;
And this Apache 2 configuration in sites.enabled:
ScriptAlias /foo /path/to/foo.cgi
Opening servers.com/foo results in this log entry in apache's error.log:
>> Dancer 1.3040 server 22693 listening on http://0.0.0.0:3000
I assumed Dancer would have detected it's running under CGI, based on the POD saying that CGI deployment "just works".
I'm pretty sure that you need to point ScriptAlias at a dispatch.cgi script like the one generated for you when you scaffold an app, which uses Plack::Runner to run the app as a CGI. Otherwise, your Dancer script will be executed and start a standalone server, as you're seeing.
I'll rework the Dancer::Deployment
documentation on CGI usage soon to more clearly reflect that - thanks for pointing out that it's not all that clear!
Okay, thanks! I'll leave this open in case you want to track the doc issue here. Feel free to close.
@bigpresh : can we close it ? or do you need to amend the documentation ?
Could do with updating the docs a bit; they've been improved, and mention using a dispatch.cgi, but I think they need to be more clear that it should be the script generated by the scaffolder, not the app itself.
They should also mention using ScriptAlias, I think.
I'll try to get a moment to deal with this soon.
@bigpresh update?
Can we help?
I'm sorry about the noobish-ness I'm a LAMP newbie.
This is only thing I have found with info on deploying to Apache with mod_perl.
Could someone list the steps or point to what needs to be done? I assumed that putting my dancer app in a virtual host folder setup to run with mod_perl would have just worked?