简体   繁体   English

如何在CGI模式下使用Apache2模块?

[英]How can I use Apache2 module in CGI mode?

my $r = shift || Apache2::RequestUtil->request;
my $request = Apache2::Request->new($r, @_);

I know it was designed to be used with mod_perl, 我知道它是设计用于mod_perl的,

but is there a workaround so that it can also be used in CGI mode? 但是有没有解决方法,使其也可以在CGI模式下使用?

Have you tried replacing those two lines with ... 您是否尝试过将这两行替换为...

my $request = CGI->new();

The Apache2::Request module wraps the mod_perl API in order to "mimic the CGI.pm routines for parsing query parameters" . Apache2 :: Request模块包装了mod_perl API,以“模拟用于解析查询参数的CGI.pm例程” So any code that uses the raw $r won't work, but code using $request might. 因此,任何使用原始$ r的代码均行不通,但使用$ request的代码则可能。

But in answer to your bigger question, the answer is no there isn't an easy way to run code written for mod_perl under CGI instead. 但是,对于更大的问题,答案是没有答案,没有简单的方法可以在CGI下运行为mod_perl编写的代码。 When writing new code you should either use a framework or write to the PSGI API which can then me deployed using CGI, FastCGI or mod_perl without changing the code. 在编写新代码时,您应该使用框架或写入PSGI API,然后可以使用CGI,FastCGI或mod_perl进行部署而无需更改代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM