【问题标题】:How to configure Lighthttpd with fastcgi如何使用 fastcgi 配置 Lighthttpd
【发布时间】:2011-12-02 21:16:05
【问题描述】:

我已经在 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,所以我不知道我应该在哪里设置这个标志。

【问题讨论】:

    标签: c++ fastcgi lighttpd


    【解决方案1】:

    该示例在开始使用 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.
     *
    

    【讨论】:

    • 但是libfcgi2.h中没有FCGX_Init()
    • @Ivan,嗯,我明白了。您是否使用来自 www.coastrd.com 的该来源的衍生产品?如果您查看他们的 libfcgi2.h 文件,您会看到一条非常相似的注释,即必须首先调用 FCXG_Init()。由于他们没有声明该函数,我怀疑存在一个微妙的错误或某种其他先决条件,他们没有更新示例。我会就这个例子直接联系他们。我所知道的 fastcgi2 的主要源代码库位于 fastcgi.com/drupal/node/5,我认为这是该公司迁移其版本的地方。
    • 尝试使用另一个库,从fastcgi.com/dist/fcgi.tar.gz 下载,解压,biult 来自“Visual Studio 命令提示符(2010)”nmake -f Makefile.nt Copy fcgi-2.4.0\libfcgi\Release \libfcgi.dll 到 fcgi-2.4.0\examples\echo-cpp\Release\libfcgi.dll 并使用 lightttpd 配置: "bin-path" => "C:\Downloads\fcgi-2.4.0\examples\echo -cpp\Release\echo-cpp.exe"
    • C:\LightTPD>LightTPD.exe -f conf\lighttpd-inc.conf -m lib -D ... 2011-10-27 10:45:46: (mod_fastcgi.c.1391 ) --- fastcgi 生成端口:9000 套接字当前:0 / 1 未知 listenType (0) 2011-10-27 10:45:46: (mod_fastcgi.c.1104) fastcgi-backend C:\Downloads\fcgi- 2.4 .0\examples\echo-cpp\Release\echo-cpp.exe 无法启动:....错误未知listenType (0) 发生在fastcgi.com/devkit/examples/echo-cpp.cpp::113 while (FCGX_Accept_r(&request) == 0)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-19
    • 2012-06-06
    • 1970-01-01
    • 2010-12-24
    相关资源
    最近更新 更多