Hi i am fastcgi newbie too and i am also have troubles. And i am try to find some help from skilled devs.
But i can help you little:
You absolutely right, Nginx expect a fastcgi app listening on tcp port 9000.
I am not a linux pro, but linux is the more native env for this software (nginx).
I alredy compiled a sample application on cpp for nginx and that the way how how can i achieved this:
Firstly you need go to http://www.fastcgi.com/ and download "The Development Kit".
Then compile a library (i not completely understand what file is a library .so or somthen else but this works):
---
[size=small]wget http://www.fastcgi.com/dist/fcgi.tar.gz
gzip fcgi-2.4.0.tar.gz -d
tar xvvf fcgi-2.4.0.tar
cd fcgi-2.4.0
./configure
make[/size]
---
then copy libs from .libs directory to /usr/lib/
then you need to code simple application like that
-----------------------------------------
[size=small]#include <string>
#include "fcgi_stdio.h"
#include <stdlib.h>
#include <iostream>
void handle(FCGX_Request request){
FCGX_FPrintF(request.out, "Content-type: text/html\r\n\r\n<TITLE>fastcgi</TITLE>\n<H1>Fastcgi:.</H1>\n");
}
int main(int argc, char* const argv[] )
{
std::string port=":9001";
int listenQueueBacklog = 400;
FCGX_Stream *in, *out, *err;
FCGX_ParamArray envp;
if(FCGX_Init()) exit(1);
int listen_socket = FCGX_OpenSocket(port.c_str(), listenQueueBacklog);
if(listen_socket < 0) exit(1);
FCGX_Request request;
if(FCGX_InitRequest(&request, listen_socket, 0)) exit(1);
int reqCounter = 0;
while(FCGX_Accept_r(&request) == 0)
{
//handle(request);
//FCGX_FPrintF(request.out, "Content-type: text/html\r\n\r\n<TITLE>fastcgi</TITLE>\n<H1>Fastcgi: Hello world.</H1>\n");
reqCounter++;
FCGX_FPrintF(request.out, "\n\r\n\r counter: %d", reqCounter);
//FCGX_Finish_r(&request);
}
return 0;
}[/size]
-----------------------------------------
then you need to compile it
g++ test.cpp -B fcgi/ -Lfcgi/libfcgi/.libs/ -lfcgi
and run it (it says nothing, just works)
after, configure nginx to pass fcgi requests to this program
nginx + this app process about 1500 http requests per second, on my virtual machine (when nginx + php fastcgihandles only about 500)
That all i can do, now i am tring to access post fileds parameters but i don't know how!
-------------------
HEY! Who knows how to develop fastcgi cpp apps, [size=large]please give some help me[/size]! Yes i know - google, but there is no information about this on the internet!
I have these questions now:
[size=large]1. how to get request post data? How to parse it?[/size]
[size=large]2. how to work with cookies, sessions?[/size]
Any help will be very very appreciated!!!
Edited 2 time(s). Last edit at 08/10/2009 12:55PM by eduard.