move backend interface modules into PLP::Backend:: namespace
[perl/plp/.git] / PLP / Backend / FastCGI.pm
diff --git a/PLP/Backend/FastCGI.pm b/PLP/Backend/FastCGI.pm
new file mode 100644 (file)
index 0000000..8ee3261
--- /dev/null
@@ -0,0 +1,69 @@
+package PLP::Backend::FastCGI;
+
+use strict;
+
+use PLP::Backend::CGI;
+use FCGI;
+use base 'PLP::Backend::CGI';
+
+our $VERSION = '1.00';
+
+sub import {
+       my $self = shift;
+       my $request = FCGI::Request();
+       while ($request->Accept() >= 0) {
+               $PLP::use_cache = !defined $ENV{PLP_CACHE} || $ENV{PLP_CACHE}; # before it's clean()ed
+               delete $ENV{PATH_TRANSLATED};
+               $self->everything();
+       }
+}
+
+1;
+
+=head1 NAME
+
+PLP::Backend::FastCGI - FastCGI interface for PLP
+
+=head1 SYNOPSIS
+
+=head2 Lighttpd
+
+Edit the configuration file (usually F</etc/lighttpd/lighttpd.conf>)
+to enable I<mod_fastcgi> (add/outcomment in server.modules), and add:
+
+    fastcgi.server = (
+        ".plp" => ((
+            "bin-path" => "/usr/bin/perl -MPLP::Backend::FastCGI",
+            "socket" => "/tmp/fcgi-plp.socket",
+        )),
+    )
+
+=head2 Apache
+
+You'll need a dispatch script (F<plp.fcgi> is included with PLP).
+Example F</foo/bar/plp.fcgi>:
+
+    #!/usr/bin/perl
+    use PLP::Backend::FastCGI;
+
+Then enable either I<mod_fastcgi> or I<mod_fcgid>, and setup F<httpd.conf>
+(often just create a F</etc/apache2/conf.d/plp>) with:
+
+    <IfModule mod_fastcgi.c>
+        AddHandler fastcgi-script plp
+        FastCgiWrapper /foo/bar/plp.fcgi
+    </IfModule>
+
+    <IfModule mod_fcgid.c>
+        AddHandler fcgid-script plp
+        FCGIWrapper /foo/bar/plp.fcgi .plp
+    </IfModule>
+
+=head1 AUTHOR
+
+Mischa POSLAWSKY <perl@shiar.org>
+
+=head1 SEE ALSO
+
+L<PLP|PLP>, L<PLP::Backend::CGI|PLP::Backend::CGI>, L<FCGI|FCGI>
+