mod_php和cgi php脚本有什么区别? [英] What are the differences between mod_php and cgi php script?
问题描述
mod_php和cgi php脚本之间有什么区别?
What are the differences between mod_php and cgi php script?
我的意思是,为什么使用mod_php而不是简单的php脚本来运行它们会更好(是吗?)
I mean, why it's better (is it?) to use mod_php instead simple php scripts, running them as CGIs?
谢谢
推荐答案
使用CGI时:PHP进程由Apache启动,它是解释PHP代码的PHP进程,而不是Apache 本身。
When using CGI : a PHP process is launched by Apache, and it is that PHP process that interprets PHP code -- not Apache itself.
从理论上讲,一种独特的PHP必须为每个请求创建流程-这会使事情变慢:Apache还要做更多工作来回答请求。
(好吧,正如@ AlReece45在评论中指出的那样,使用FastCGI可以使它更好)
In theory, a distinct PHP process has to be created for each request -- which makes things slower : Apache has more work to do to answer a request.
(Well, as pointed out by @AlReece45 in a comment, this can be made better using FastCGI)
将PHP用作Apache模块( mod_php
或 mod_php5
),PHP解释器在Apache进程内部有点 嵌入式:没有外部PHP进程。
When using PHP as an Apache module (mod_php
, or mod_php5
), the PHP interpreter is kind of "embedded" inside the Apache process : there is no external PHP process.
这意味着:
- 无需分叉(更快)
- Apache和PHP之间的更好通信
一般来说,我会说 mod_php
是最常用的解决方案。
Generally speaking, I would say that mod_php
is the solution that's used the most.
这篇关于mod_php和cgi php脚本有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!