gpt4 book ai didi

c++ - 如何使用 fastcgi 配置 Lighttpd

转载 作者:太空狗 更新时间:2023-10-29 23:19:40 26 4
gpt4 key购买 nike

我已经在 Windows 上安装了 LightTPD。它通常在没有 fastcgi 的情况下启动。然后我复制/粘贴其中一个 fastCGI 示例

#include <sstream>  // manipulate strings (integer conversion)
#include <string> // work with strings in a more intuitive way
#include "libfcgi2.h" // Header file for libfcgi2.dll (linked with libfcgi2.lib)

using namespace std;

int main( )
{
printf("Start...\r\n");
FCGX_REQUEST Req = { 0 }; // Create & Initialize all members to zero
int count(0);
string sReply;
ostringstream ss;

FCGX_InitRequest( &Req, 0, 0 ); // FCGX_DEBUG - third parameter

// Open Database
while(true)
{
if( FCGX_Accept_r(&Req) < 0 ) break; // Execution is blocked here until a Request is received
count++;
ss << count; // Stringstream is a typesafe Integer conversion
sReply = "Content-Type: text/html\r\n\r\n Hello World " + ss.str();
FCGX_PutStr( sReply.data(), sReply.length(), Req.pOut );
ss.str(""); // clear the string stream object
}

// Close Database
printf("End...\r\n");
return 0;
}

并尝试使用以下配置启动服务器:

server.modules              = (
...
"mod_fastcgi",

....

fastcgi.server = ( ".exe" =>
( "" =>
( "bin-path" => "C:\FastCGI\Examples\C++\Ex_Counter.exe",
"port" => 8080,
"min-procs" => 1,
"max-procs" => 1
)
)
)

启动时出现错误:

C:\LightTPD>LightTPD.exe -f conf\lighttpd-inc.conf -m lib -D
cygwin warning:
MS-DOS style path detected: conf\lighttpd-inc.conf
Preferred POSIX equivalent is: conf/lighttpd-inc.conf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
2011-10-07 12:50:25: (log.c.166) server started
2011-10-07 12:50:25: (mod_fastcgi.c.1367) --- fastcgi spawning local
proc: C:\FastCGI\Examples\C++\Ex_Counter.exe
port: 8080
socket
max-procs: 1
2011-10-07 12:50:25: (mod_fastcgi.c.1391) --- fastcgi spawning
port: 8080
socket
current: 0 / 1
2011-10-07 12:50:25: (mod_fastcgi.c.1104) the fastcgi-backend C:\FastCGI\Example
s\C++\Ex_Counter.exe failed to start:
2011-10-07 12:50:25: (mod_fastcgi.c.1108) child exited with status 0 C:\FastCGI\
Examples\C++\Ex_Counter.exe
2011-10-07 12:50:25: (mod_fastcgi.c.1111) If you're trying to run your app as a
FastCGI backend, make sure you're using the FastCGI-enabled version.
If this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2011-10-07 12:50:25: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed.
2011-10-07 12:50:25: (server.c.942) Configuration of plugins failed. Going down.

我没有使用 php,所以我不知道应该在哪里设置这个标志。

最佳答案

看起来该示例在开始使用 FCGX 库函数之前调用 FCGX_Init() 失败。这将导致 FCGX_Accept_r 返回非 0 错误条件,并导致您的示例以您看到的日志文件中指示的 0 状态退出。

来自 fcgiapp.h :

/*
*----------------------------------------------------------------------
*
* FCGX_Accept_r --
*
* Accept a new request (multi-thread safe). Be sure to call
* FCGX_Init() first.
*

关于c++ - 如何使用 fastcgi 配置 Lighttpd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7685521/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com