mod_php vs cgi vs fast-cgi
我一直在尝试理解将 php 加载为 apache 模块与其他模块的确切含义/目的。
当 php 作为 apache 模块安装时,到底会发生什么?例如,每次php请求到来时都会读取php-ini文件,还是单独加载php模块时会读取php-ini文件?
I have been trying to understand the exact meaning/purpose of loading php as an apache module vs the rest.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当 PHP 模块在 mod_php、FastCGI 和 FPM 中加载时,会读取 php.ini。在常规 CGI 模式中,必须在运行时读取配置文件,因为没有任何类型的预分叉进程。
我认为将 PHP 作为 Web 服务器内的模块运行的唯一真正优势是配置可能更容易。当您在 FastCGI 或 FPM 模式下运行它并且可以使用线程或事件(而不是分叉)Apache 时,或者当您可以完全抛弃 Apache 时,您会获得更好的性能。
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.
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.
此链接可能会有所帮助:http://2bits。 com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html
This link may help: http://2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html
对于 Apache 模块,加载模块时会读取 php.ini。 PHP CGI 使用 PHP 解释器可执行文件,就像任何其他 shell 脚本一样。由于每次调用不涉及任何状态,因此在 CGI 情况下每次都必须读取配置文件。
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.