Project

General

Profile

How to configure Lighthttpd with fastcgi

Added by ivan over 13 years ago

I've installed LightTPD on windows. It starts without fastcgi normally. Then I copy/paste one of the fastCGI examples

#include <sstream>  // manipulate strings (integer conversion) 
#include <string>   // work with strings in a more intuitive way

using namespace std;

#include "libfcgi2.h" // Header file for libfcgi2.dll (linked with libfcgi2.lib)

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;
}

and trying to start server with config edited with:

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

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

And gain error on start up:

C:\LightTPD>LightTPD.exe -D -f conf\lighttpd-inc.conf -m lib
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 16:33:03: (log.c.166) server started
2011-10-07 16:33:03: (mod_fastcgi.c.1367) --- fastcgi spawning local
        proc: C:\FastCGI\Examples\C++\Ex_Counter.exe
        port: 8080
        socket
        max-procs: 1
2011-10-07 16:33:03: (mod_fastcgi.c.1391) --- fastcgi spawning
        port: 8080
        socket
        current: 0 / 1
2011-10-07 16:33:03: (mod_fastcgi.c.1104) the fastcgi-backend C:\FastCGI\Examples\C++\Ex_Counter.exe failed to start:
2011-10-07 16:33:03: (mod_fastcgi.c.1108) child exited with status 0 C:\FastCGI\Examples\C++\Ex_Counter.exe
2011-10-07 16:33:03: (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 16:33:03: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed.
2011-10-07 16:33:03: (server.c.942) Configuration of plugins failed. Going down.

I'm not using php, so i don't know where i should set this flag.

Thanks.


Replies (4)

RE: How to configure Lighthttpd with fastcgi - Added by Rudolf over 13 years ago

Hi Ivan,

I can calm you: your errormessage has nothing to do with your C-Coding. It happens also for PHP and Perl. Spent hours to find a solution but failed. I assume a bug in 1.4.28 and unfortunately version for 1.4.29 is not yet avaliable for windows. I keep searching and will inform you.
Regards
Rudolf

RE: How to configure Lighthttpd with fastcgi - Follow up - Added by Rudolf over 13 years ago

Hi Ivan,

after heavy working on this topic I had to realize that fastcgi is not possible on the WINDOWS-Version of lighttpd. Digging in the C-Code of mod_fastcgi.c shows that is has something to do with the forking mechanism which is a little bit different from the one used in linux. Fastcgi is possible if you address a remote server (what can be also localhost) but this would require a fastcgi-server. With "bin-path" as in your example I am afraid you can't make it. At least I had no success and I did also not find any post in a forum that confirms that fastcgi used with bin_path + lighttpd is working on WINDOWS.

At least I do hope that I am wrong with this assumption, may be I would have found a solution after many hours, but I dont have the time. So my solution was: switch back to Apache, there it works really fine.

Regards
Rudolf

RE: How to configure Lighthttpd with fastcgi - Added by dexli over 13 years ago

Moin Rudolf,

can you be more specific?
Do you have tested this without using Cygwin ??

Bis die Tage
Norbert

RE: How to configure Lighthttpd with fastcgi - Added by Rudolf over 13 years ago

Moin Norbert,

in my tests cygwin was not involved. I downloaded lighthttpd for windows (pure windows, no unix, no cygwin). It works as expected but I was not able to run a fastcgi-script. In my opinion the forking mechanism works different on windows compared to unix. There is the problem.

Gruesse
Rudolf

    (1-4/4)