PHP如何与HTTP服务器交互?(如lighttpd)(复制)

时间:2021-09-23 20:59:12

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

可能重复:我从未真正理解:什么是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?

在lighttpd配置中,我们定义了两条路径(如下所示),其中一个是PHP的二进制文件,另一个是套接字路径。我的问题是,lighttpd从哪个点获取PHP创建的最终HTML输出?二进制文件是否为lighttpd提供一个响应输出?还是在其他地方创建一个临时文件并由服务器获取?

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php-cgi",
                     "socket" => "/tmp/php.socket"
                 )))

2 个解决方案

#1


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.

PHP可以作为CGI二进制文件运行,也可以作为Apache模块运行。当作为CGI二进制文件使用时,HTTP服务器将通过管道或命名管道与PHP通信。它们可以利用一种不需要任何磁盘访问的进程间通信形式stdout。如果作为Apache模块运行,PHP实际上是Apache服务器的一部分。这比作为CGI执行要快得多,但是有一些安全限制。

#2


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.

从我的理解来看,binpath是用来启动FastCGI服务器(如果还没有启动的话),而套接字用于将请求代理到服务器上。

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.

最终的HTML因此从/tmp/php中提取。处理完请求后的套接字;它是一个命名管道,而不是网络套接字,但是它们在其他方面非常相似。

#1


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.

PHP可以作为CGI二进制文件运行,也可以作为Apache模块运行。当作为CGI二进制文件使用时,HTTP服务器将通过管道或命名管道与PHP通信。它们可以利用一种不需要任何磁盘访问的进程间通信形式stdout。如果作为Apache模块运行,PHP实际上是Apache服务器的一部分。这比作为CGI执行要快得多,但是有一些安全限制。

#2


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.

从我的理解来看,binpath是用来启动FastCGI服务器(如果还没有启动的话),而套接字用于将请求代理到服务器上。

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.

最终的HTML因此从/tmp/php中提取。处理完请求后的套接字;它是一个命名管道,而不是网络套接字,但是它们在其他方面非常相似。