I've got a website where each web page is put together right into a binary (I've 100 web pages, well, i have 100 binaries). Apache's .htaccess consists of the road "SetHandler cgi-script" which instructs apache to make use of CGI whenever a binary (web page) is asked for.
How do i modify this site to make use of FastCGI rather than CGI ?
Will I have to include this header and employ this while loop (FastCGI.com) in each one of the 100 binaries and modify .htaccess to "SetHandler fastcgi-script" ?
#include "fcgi_stdio.h" // instead of stdio.h while(FCGI_Accept() >= 0)
Just how will FastCGI work exactly ? Apache will dispatch web pages using 1 persistent process for the whole website or maybe there is 1 persistent process for each one of the 100 binaries ?
A FastCGI script is really a network server that listens for connections inside a loop. The net server forward demands towards the FCGI server which transmits back some dynamically produced content - throughout a socket connection. Thus a FCGI script is faster than CGI because it is not re-created for every request.
I do not realise why you'll need 100 binaries for 100 pages. Just one script is sufficient to generate content for 100 pages, according to some request parameter. The FCGI server also needs to scale pretty much for multiple connections because it is usually designed to poll around the socket file descriptor. (Consider the code from the implementation to make certain of the).
To create 100 pages you do not always need 100 if claims. Think about this pseudo-code:
hash_table page_generators; // map page types to function objects (or function pointers) page_generators["login_page"] = handle_login_page_fn; page_generators["contact_page"] = handle_contact_page_fn; // ... and so on // request handler page_type = request.get("page_type"); fn = page_generators[page_type]; if (fn == NULL) return "<html><body>Invalid request</body></html>"; else return fn(request);
It can be a little off-subject, but: pst is appropriate.
Why not use ASP.Internet MVC/mod-mono ?
It will just what you would like (compile pages right into a binary), exactly that it compiles pages to C# rather than C (you may also choose VB.Internet, but that is not such advisable on Linux, because the Linux compiler does not yet support VB.Internet > .Internet 2. it now supports C# as much as 4. however).
If you want to develop on Linux, you could use monodevelop, and when you are on Home windows and don't wish to purchase VisualStudio, you could use sharpdevelop (free) http://www.icsharpcode.net/OpenSource/SD/Default.aspx
Like a side note: why not compile the 100 exe's into 100 dll's this way you need to simply switch the input page and pass as parameter.