Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes for scaffolded apps + Dancer::Deployment cleanup (CGI)

  • Loading branch information...
commit 01756f230362dff45655b542f4077276d0bb60c9 1 parent b50b29c
Alexis Sukrieh authored
Showing with 29 additions and 20 deletions.
  1. +1 −0  Makefile.PL
  2. +20 −16 lib/Dancer/Deployment.pod
  3. +8 −4 script/dancer
View
1  Makefile.PL
@@ -23,6 +23,7 @@ WriteMakefile1(
PREREQ_PM => {
# non-core
+ 'LWP' => '0',
'HTTP::Body' => '1.07', # needed for cleanup()
'HTTP::Server::Simple::PSGI' => '0.11',
'MIME::Types' => '0',
View
36 lib/Dancer/Deployment.pod
@@ -10,31 +10,35 @@ choices when deploying your Dancer app.
=head2 Running as a cgi-script

It has occurred to me that using a VirtualHost container means we are not really using or app as a script at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-In providing ultimate flexibility in terms of deployment, your Dancer app can be run
-as a simple cgi-script out-of-the-box. No additional web-server configuration needed.
-Your web server should recognize .cgi files and be able to serve Perl scripts.
-The Perl module Plack::Runner is required. Access your app from the browser:
-
- http://localhost/myapp/dispatch.cgi
- 500 Internal Server Error - Wrong
-
- http://localhost/myapp/dispatch.cgi/
- 200 OK - Right
+In providing ultimate flexibility in terms of deployment, your Dancer app can
+be run as a simple cgi-script out-of-the-box. No additional web-server
+configuration needed. Your web server should recognize .cgi files and be able
+to serve Perl scripts. The Perl module Plack::Runner is required.
Start by adding the following to your apache configuration:
<VirtualHost *:80>
- ScriptAlias /myapp /path/to/app/public/dispatch.cgi/
+ ServerName your.server.domain
+
+ # The DocumentRoot should point to your "public" directory
+ DocumentRoot "/path/to/dancer/public"
+
+ <Directory "/path/to/dancer/public">
+ AllowOverride None
+ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch -Indexes
+ Order allow,deny
+ Allow from all
+ AddHandler cgi-script .cgi
+ </Directory>
+
</VirtualHost>
Enable Pretty-URLs if your web server supports .htaccess files and mod_rewrite.
-Place this code in a file called .htaccess in your application's root folder:
+Place this code in a file called .htaccess (or directly in your VirtualHost
+configuration) in your application's root folder:
# BEGIN dancer application htaccess
DirectoryIndex dispatch.cgi/
- AddHandler cgi-script .cgi
- Options +ExecCGI +FollowSymLinks -Indexes
-
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
@@ -43,7 +47,7 @@ Place this code in a file called .htaccess in your application's root folder:
Now you can access your dancer application URLs as if you were using the embedded web server.
- http://localhost/myapp/
+ http://localhost/
This option is a no-brainer, easy to setup, low maintenance but serves requests
slower than all other options.
View
12 script/dancer
@@ -257,14 +257,18 @@ I\'m in <code>[%appdir%]/views/index.tt</code>
"dispatch.cgi" =>
"$PERL_INTERPRETER
use Plack::Runner;
-Plack::Runner->run('[% appdir %]/$DANCER_SCRIPT.pl');
+use Dancer ':syntax';
+my \$psgi = path(dirname(__FILE__), '..', '$DANCER_SCRIPT.pl');
+Plack::Runner->run(\$psgi);
",
"dispatch.fcgi" =>
"$PERL_INTERPRETER
use Plack::Handler::FCGI;
+use Dancer ':syntax';
-my \$app = do('[% appdir %]/$DANCER_SCRIPT.pl');
+my \$psgi = path(dirname(__FILE__), '..', '$DANCER_SCRIPT.pl');
+my \$app = do(\$psgi);
my \$server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
\$server->run(\$app);
",
@@ -273,7 +277,7 @@ my \$server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
"$PERL_INTERPRETER
use Dancer;
-use lib ('lib');
+use lib path(dirname(__FILE__), 'lib');
load_app '$appname';
dance;
",
@@ -285,7 +289,7 @@ use Dancer ':syntax';
our \$VERSION = '0.1';
-get '/' => sub {
+get qr{/(index.html)?/?} => sub {
template 'index';
};
Please sign in to comment.
Something went wrong with that request. Please try again.