Dancer icon indicating copy to clipboard operation
Dancer copied to clipboard

Deployment under CGI on Apache2 doesn't work

Open wolverian opened this issue 13 years ago • 6 comments

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".

wolverian avatar May 12 '11 15:05 wolverian

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!

bigpresh avatar May 12 '11 16:05 bigpresh

Okay, thanks! I'll leave this open in case you want to track the doc issue here. Feel free to close.

wolverian avatar May 12 '11 18:05 wolverian

@bigpresh : can we close it ? or do you need to amend the documentation ?

dams avatar Jul 05 '11 22:07 dams

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 avatar Jul 06 '11 13:07 bigpresh

@bigpresh update?

Can we help?

xsawyerx avatar Mar 01 '12 10:03 xsawyerx

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?

gideondsouza avatar Dec 29 '12 15:12 gideondsouza