6

Possible Duplicate:
I never really understood: what is CGI?

In the lighttpd config, we define two paths (as shown below), one of them is the binary of PHP, the other is the socket path. My question is, in which point does the lighttpd fetches the final HTML output created by PHP? Does the binary give an output to lighttpd as a response? Or does it create a temporary file in another place and server fetches it?

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php-cgi",
                     "socket" => "/tmp/php.socket"
                 )))
Community
  • 1
  • 1
tolga
  • 2,462
  • 4
  • 31
  • 57
  • Pipes usually (see [CGI](http://en.wikipedia.org/wiki/Common_Gateway_Interface)). But since this config specifies a socket, you're presumably using the FastCGI binary. – mario Dec 27 '12 at 22:41
  • 1
    Not a duplicate; the config snippet is about FastCGI, not CGI. bin-path means lighty will spawn the backend (opposed to spawning externally), the socket is the path to a "unix socket" (not a named pipe, a real socket). lighty will connect to this socket for each request, the same way a browser will connect to the webserver - but it uses a different protocol for the details. – Stefan Jan 23 '13 at 13:55
  • Would you please remove the "duplicate" statement, because this question is not a duplicate. – tolga Oct 25 '13 at 05:45

2 Answers2

1

From my understanding, the bin-path is used to fire up the FastCGI server (if it's not started yet) whereas the socket is used to proxy the request into the server once started.

The final HTML is therefore pulled from /tmp/php.socket after the request has been processed; it's a named pipe as opposed to a network socket but they're quite similar in any other respect.

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
1

PHP can run as a CGI binary, or as an Apache module. When being used as a CGI binary, the HTTP server will communicate with PHP via pipes or named pipes. These can utilize stdout which is a form of interprocess communication which does not require any disk access. If run as an Apache module, PHP is effectively part of the Apache server. This is significantly faster than being executed as a CGI, but has some security limitations.

Jordan Mack
  • 8,223
  • 7
  • 30
  • 29