【问题标题】:How to configure and run a fastcgi application using Lighthttpd如何使用 Lighttpd 配置和运行 fastcgi 应用程序
【发布时间】:2009-02-18 12:13:05
【问题描述】:

我已经为 Windows 安装了 Lighthttpd,并且我用 c++ 创建了一个使用 fastcgi 库的简单程序。我会在这里发布代码...

#include "fcgi_stdio.h" 
#include <stdlib.h>
int count;
void initialize(void)
{
  count=0;
}
void main(void)
{
  initialize();
  while (FCGI_Accept() >= 0)   {
    printf("Content-type: text/html\r\n"
           "\r\n"
           "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
           "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
           "Request number %d running on host <i>%s</i>\n",
            ++count, getenv("SERVER_HOSTNAME"));
  }
}

我使用 lightttpd-inc.conf 中的以下配置在 lighthttpd 中生成了 fastcgi 应用程序

fastcgi.server             = ( ".exe" =>
                               ( "" => 
                                 (
                                   "bin-path" => "D:\tinycgi.exe",
                                   "port" => 8080,
                                   "min-procs" => 1,
                                   "max-procs" => 1
                                 )
                               )
                             )

在使用浏览器发送请求时,服务器在控制台中响应此消息

2009-02-18 16:08:34: (mod_fastcgi.c.2494) unexpected end-of-file (perhaps the fa
stcgi process died): pid: 0 socket: tcp:localhost:8080
2009-02-18 16:08:34: (mod_fastcgi.c.3325) response not received, request sent: 1
024 on socket: tcp:localhost:8080 for /new/tinycgi.exe , closing connection

我认为 fastcgi 应用程序没有正确生成。

谢谢你, 瓦伦

【问题讨论】:

  • 您可以尝试使用
     标签重新格式化代码,因为它几乎无法阅读?

标签: c++ fastcgi lighttpd


【解决方案1】:

首先,main 应该返回一个 int(不是 void)。 问题很可能是您没有调用 FCGX_Init() 也没有初始化请求(使用 FCGX_InitRequest())。

如果要检查应用程序是否正确生成,应写入日志文件,如果 lighttpd 没有启动应用程序,则不会创建日志文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 1970-01-01
    相关资源
    最近更新 更多