分类:
2009-03-30 07:18:30
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" ) } }