什么是 mod_php? [英] What is mod_php?

查看:25
本文介绍了什么是 mod_php?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读 Zend 教程时,我遇到了以下语句:

While going through a Zend tutorial, I came across the following statement:

请注意,.htaccess 中的 php_flag 设置仅在您使用 mod_php 时才有效.

Note that the php_flag settings in .htaccess only work if you are using mod_php.

谁能解释一下这是什么意思?

Can someone explain what that means?

推荐答案

mod_php 表示 PHP,作为 Apache 模块.

基本上,当加载 mod_php 作为 Apache 模块时,它允许 Apache 解释 PHP 文件(那些由 mod_php 解释).

Basically, when loading mod_php as an Apache module, it allows Apache to interpret PHP files (those are interpreted by mod_php).


(至少)有两种运行 PHP 的方式,当使用 Apache 时:


EDIT : There are (at least) two ways of running PHP, when working with Apache :

  • 使用 CGI:Apache 启动一个 PHP 进程,解释 PHP 代码的是 PHP 进程——而不是 Apache 本身
  • 将 PHP 用作 Apache 模块 (称为 mod_php) :然后 PHP 解释器被嵌入"在 Apache 进程中:没有外部 PHP 进程——这意味着 Apache 和 PHP 可以更好地通信.


并且在评论后重新编辑:使用 CGI 或 mod_php 取决于您:这只是您的网络服务器配置的问题.


And re-edit, after the comment : using CGI or mod_php is up to you : it's only a matter of configuration of your webserver.

要知道您的服务器当前使用的是哪种方式,您可以检查phpinfo()<的输出/code> :应该有一些东西表明 PHP 是通过 mod_php (或 mod_php5) 还是通过 CGI 运行.

To know which way is currently used on your server, you can check the output of phpinfo() : there should be something indicating whether PHP is running via mod_php (or mod_php5), or via CGI.

您可能还想查看php_sapi_name() 函数:它返回 Web 服务器和 PHP 之间的接口类型.

You might also want to take a look at the php_sapi_name() function : it returns the type of interface between web server and PHP.


如果您检查 Apache 的配置文件,在使用 mod_php 时,应该有一个 LoadModule 行,如下所示:


If you check in your Apache's configuration files, when using mod_php, there should be a LoadModule line looking like this :

LoadModule php5_module        modules/libphp5.so

(右侧的文件名可以不同——例如,在 Windows 上,它应该是 .dll)

这篇关于什么是 mod_php?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆