【问题标题】:Testing FastCGI script in Perl using standalone Perl FastCGI / FCGI web server使用独立的 Perl FastCGI / FCGI Web 服务器在 Perl 中测试 FastCGI 脚本
【发布时间】:2010-06-07 09:12:48
【问题描述】:

我有一个 FastCGI Perl Web 应用程序(使用 CGI::Fast 编写,但这不重要),我想在 FastCGI 模式下进行测试

我可以使用什么 Perl 模块来运行 FastCGI 应用程序(该模块应该从 CPAN 安装,最好不使用额外的库),这样我就可以指向 Web 浏览器,例如到http://localhost:5000检查它是否工作正常?

更好,是否有一些 Test::* 模块允许自动测试 FastCGI 应用程序,如 FastCGI 应用程序?


2010 年 6 月 7 日添加:
Perl 中似乎没有独立的 FastCGI 服务器;或者至少我没有找到。我在 CPAN 上找到的 FCGI / FastCGI 相关模块是关于编写 FastCGI 应用程序,或连接到现有的 FastCGI 服务器。

【问题讨论】:

  • 我正在使用 C 语言实现 FastCGI。它被设计为可中断的解析器(使用 FSM 实现),用于异步服务器模型,因此它本身不执行任何 I/O。它可以很容易地集成到任何服务器或程序模型中。它提供了电线两侧的需要。欢迎随时check it out

标签: perl testing webserver fastcgi


【解决方案1】:

我不知道有什么模块可以让您专门测试快速 CGI 应用程序。为了在开发过程中运行 Fast CGI 脚本进行测试,我通常会设置一个像这样的小型 lighttpd 服务器:

$HTTP["url"] =~ "^/[^/]*$" {
    fastcgi.server = (
        "/" => ((
            "socket" => "/tmp/myapp.sock",
            "bin-path" => "/path/to/my/fastcgi/script.pl",
            "check-local" => "disable",
            "allow-x-send-file" => "enable",
        )),
    )
}

# Use this if you also want to serve static files directly (not through your CGI app).
$HTTP["url"] =~ "^/static/.*$" {
    url.rewrite-once = ( "^/static/\(.*\)$" => "static/$1" )
}

您可能还想将端口设置为 5000 或任何高于 1024 的端口,以便您可以以用户身份运行它。将文件保存在您的项目目录中并像这样运行 lighttpd:

/usr/sbin/lighttpd -f lighttpd.conf -D

【讨论】:

  • 像这样启动 lig​​httpd lighttpd -f config.cnf -D 我需要在上面添加这些行以获得完整的独立 lighttpd conf:server.document-root = "/var/www/" server.port = 8082 server.errorlog = "error.log" static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) server.modules += ( "mod_fastcgi" )
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-09-27
  • 2013-12-21
  • 2010-10-22
  • 2011-11-04
  • 2021-07-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多