From the client browser to the Apache httpd webserver there is a clear defined protocol, HTTP, via TCP/IP (sockets). I'm having hard time to understand what channel/protocol is used from the Apache httpd webserver to Perl or PHP or CGI? Is it Inter-Process Communication via sockets or pipse or message queue or signals? Could someone shed light on what is really going on behind the scene? Is it as if the Apache httpd webserver executes another program (Perl or PHP) and captures the output and then resends it to client browser?
From Linux Server Security:
The CGI protocol doesn't specify how the web server should communicate with the CGI program. There have been two main solutions:
Standalone CGI programs
Apache receives a CGI request, opens a two-way pipe to an external program, sends it the CGI input data, and returns the program's output to the client. As a separate process, the program can crash without bringing down the web server. The down side is that it's relatively slow to start a new process.
Built-in CGI programs
The program is rewritten as an Apache module and incurs its startup cost only when an Apache process starts. This is much faster than an external program and has access to Apache's internals and other modules. The most popular modules for CGI in Apache are the interpreter engines for Perl (mod_perl) and PHP (mod_php).