Как настроить Lighthttpd с fastcgi - PullRequest
       57

Как настроить Lighthttpd с fastcgi

3 голосов
/ 07 октября 2011

Я установил LightTPD на Windows. Начинается без 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, поэтому я не знаю, где мне установить этот флаг.

1 Ответ

0 голосов
/ 19 октября 2011

Похоже, что в примере не удалось вызвать FCGX_Init (), прежде чем он начал использовать функции библиотеки FCGX.Это приведет к тому, что FCGX_Accept_r вернет состояние ошибки, отличное от 0, и приведет к выходу из вашего примера с состоянием 0, указанным в файле журнала, который вы просматриваете.

From fcgiapp.h :

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