如何使用 Lighthttpd 配置和运行 fastcgi 应用程序

发布于 2024-07-14 13:18:06 字数 1573 浏览 6 评论 0原文

我已经安装了适用于 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应用程序未正确生成。

谢谢你, 瓦伦

i've installed Lighthttpd for windows and i'd created a simple program in c++ which uses fastcgi libraries. i'll post the code here...

#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"));
  }
}

I've spawned the fastcgi application in lighthttpd using the below configuration in lightttpd-inc.conf

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

while sending a request using the browser the server is responding with this message in the console

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

I think the fastcgi application is not spawned correctly.

Thank you,
Varun

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌化 2024-07-21 13:18:06

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

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

First of all, main should return an int (not void).
The problem is most likely that you didn't call FCGX_Init() and didn't initialize the request (with FCGX_InitRequest()) either.

If you want to check if the application is spawned correctly, you should write to a log file, if lighttpd doesn't start the application, the log file won't be created.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文