Chinaunix首页 | 论坛 | 博客
  • 博客访问: 589983
  • 博文数量: 207
  • 博客积分: 10128
  • 博客等级: 上将
  • 技术积分: 2440
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-10 21:40
文章分类

全部博文(207)

文章存档

2009年(200)

2008年(7)

我的朋友

分类:

2009-03-30 07:18:30

From:

Yet Another Using a Perl dispatcher instead of mod_perl

I am using CGI::Application and lighty 1.4.11. The only module you need to install is CGI::Fast which is a pure perl module. The C::A app runs fine with little change in the instance script. CGI::Application::Dispatch can be used if you use multiple instance scripts. -- Qiang@cgiapp from freenode.

here is my instance script ( or dispatcher ).

#!/usr/bin/perl -w
use strict;
use warnings;
use My::App;
use CGI::Fast();

while (my $q = new CGI::Fast){
    my $webapp = My::App->new( QUERY => $q );
    $webapp->run();
}

#### below is what i have for mod_perl. 
#### you can see there isn't much change after migrating to lighty.
#!/usr/bin/perl -w
use strict;
use warnings;
use My::App;
use CGI::Fast;

my $webapp = My::App->new();
$webapp->run();

here is my lighty conf:

       ### here is the fastcgi server
       $HTTP["host"] == "dev.example.com" {
            var.root    = "/path/to/app/root/"
            server.document-root = var.root + "htdocs/"

            url.rewrite = ( "^/static/.*"        => "$0",
                            "^/([a-zA-Z_]+)$"    => "/index.pl/$1",
                            "^/([a-zA-Z_]+/.*)$" => "/index.pl/$1"
                           )

            fastcgi.server = ( ".pl" => ((
                                 "bin-path"        => var.root + "htdocs/index.pl",
                                 "bin-environment" => ( "PERL5LIB" => var.root + "lib",
                                                        "CGIAPP_CONFIG_FILE" => var.root + "conf/my.conf" ),
                                 "socket"          => "/tmp/perl.socket",
                                 "check-local"     => "disable",
                                 "min-procs"       => 2,
                                 "max-procs"       => 5,
                                 "idle-timeout"    => 20
                 )))
        }
        
        # this is for plain cgi
        $HTTP["host"] == "dev1.example.com" {
            alias.url  = ( "/bin/" => "/app/htdocs/bin/" )
            $HTTP["url"] =~ "^/bin" {
                    setenv.add-environment = ( "DEVMODE" => "dev" )
                    cgi.assign = ( ".pl" => "/usr/bin/perl" )
            }
        }
阅读(537) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~