php mod_php vs cgi vs fast-cgi
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3953793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mod_php vs cgi vs fast-cgi
提问by Karthick
I have been trying to understand the exact meaning/purpose of loading php as an apache module vs the rest.
我一直在试图理解将 php 作为 apache 模块与其他模块加载的确切含义/目的。
When php is installed as an apache module, what exactly happens? For example, does reading the php-ini file happen every time the php request comes or when the php module is loaded alone?
当 php 作为 apache 模块安装时,究竟会发生什么?比如是每次php请求来还是单独加载php模块时读取php-ini文件?
采纳答案by Emil Vikstr?m
php.ini is read when the PHP module is loaded in both mod_php, FastCGI and FPM. In regular CGI mode, the config file have to be read at runtime because there's no preforked processes of any kind.
当在 mod_php、FastCGI 和 FPM 中加载 PHP 模块时,将读取 php.ini。在常规 CGI 模式下,必须在运行时读取配置文件,因为没有任何类型的预分叉进程。
I think the only real advantage of running PHP as a module inside the web server is that the configuration might be easier. You get a lot better performance when you run it in FastCGI or FPM mode and can use a threaded or evented (instead of forked) Apache, or when you can throw out Apache altogether.
我认为将 PHP 作为一个模块在 Web 服务器中运行的唯一真正优势是配置可能更容易。当您在 FastCGI 或 FPM 模式下运行它并且可以使用线程或事件(而不是分叉)Apache 时,或者当您可以完全抛弃 Apache 时,您会获得更好的性能。
回答by stormwild
This link may help: http://2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html
此链接可能会有所帮助:http: //2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html
Conclusion
If pure speed is what you are after, then stay with mod_php.
However, for better resource usage and efficiency, consider moving to fcgid.
结论
如果您追求的是纯粹的速度,那么请继续使用 mod_php。
但是,为了更好地使用资源和提高效率,请考虑转向 fcgid。
回答by Anand
php.ini is read when the module is loaded in the case of an Apache module. PHP CGI uses a php interpreter executable like any other shell script would do. Since there is no state involved at each invocation, the config file would have to be read every single time in case of CGI.
如果是 Apache 模块,则在加载模块时读取 php.ini。PHP CGI 使用 php 解释器可执行文件,就像任何其他 shell 脚本一样。由于每次调用都没有涉及状态,因此在 CGI 的情况下,每次都必须读取配置文件。