Nginx & Fastcgi - what is it?
Could someone please briefly explain NGinx & Fastcgi as if you're technically minded 10 year old son just asked you please?
I'm in the midst (been at it 2 weeks now) of getting to grips with installing it and I just realised that I don't really know what it is.
Thanks if you can spare the time
TT
4 Replies
fastcgi is a protocol that works on the backend that connects your interpretor of choice with the webserver. Because the webserver usually doesn't do the job of interpreting your code (well, with mod_php|perl|foo it does, but that's another story and a bad idea), something needs to execute your app code. Fastcgi is the method in which your app communicates this information with your webserver.
@tentimes:
Could someone please briefly explain NGinx & Fastcgi as if you're technically minded 10 year old son just asked you please?
Fastcgi is a protocol to hand off a request from a web server to another process to execute it, and to communicate back the result to be sent by the original server to the client. By allowing that second process to remain running it is more efficient than traditional CGI which had to execute a new child process for each request.
In terms of mental model, it pretty much works just like a normal web proxy but using its own protocol rather than HTTP.
– David
> (well, with mod_php|perl|foo it does, but that's another story and a bad idea)
Why is running mod_php a "bad idea"?
@waldo:
Why is running mod_php a "bad idea"?
1. The PHP engine gets loaded even if Apache is only serving a tiny static file. This wastes RAM. You shouldn't have to run a 15MB process to serve 15KB files.
2. PHP scripts are executed with the same privileges as the web server. This leads to various security issues when you have more than one website on the same server, especially if those sites are administered by different people. Various stopgap measures such as openbasedir and safemode have been invented, but they're nowhere near as secure as running a separate FastCGI process.
3. Because PHP is not thread-safe, modphp prevents the use of mpmworker, which is the officially preferred multiprocessing model for recent versions of Apache.
These things probably don't matter, though, if you only have one site on your server (or a bunch of sites all administered by you) and you don't have a lot of visitors.