编辑

编辑

我现在很困惑如何在不同的环境中将文件解析为 PHP AddHandler

本地服务器

Windows 7 / Apache2.2 / PHP 5.2(thread safe

AddHandler x-httpd-php .php              # does not work
AddHandler x-httpd-php52 .php            # does not work
AddHandler application/x-httpd-php .php  # works

我刚刚将 PHP 升级到 5.3(切换到non thread safe

AddHandler x-httpd-php .php              # does not work
AddHandler x-httpd-php53 .php            # does not work
AddHandler application/x-httpd-php .php  # does not work <-- works on 5.2
AddHandler php5-script .php              # does not work

# AddHandler... and I'v tried some of others, none of them works

虚拟主机

CentOS/Apache2.2/PHP 5.3

AddHandler x-httpd-php .php              # does not work
AddHandler x-httpd-php53 .php            # works
AddHandler application/x-httpd-php .php  # does not work (works prior to 5.2)

我的问题:

  1. 为什么AddHandler application/x-httpd-php .php当我将 PHP 升级到 5.3 非线程安全版本后,它就无法在本地服务器上运行?我还需要做其他额外工作吗?

  2. 何时/何地/如何使用x-httpd-phpapplication/x-httpd-phpphp-script5other types of format?这些是否依赖于操作系统 / Apache 版本 / PHP 版本 / PHP 类型?

编辑

好吧,我要回答我自己的第一个问题

将 PHP 作为 Apache 模块运行

# httpd.conf

PHPIniDir "C:/PHP"
LoadModule php5_module "C:/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php

将 PHP 作为 CGI 二进制文件运行

# httpd.conf

ScriptAlias /PHP/ "C:/PHP/"
Action application/x-httpd-php "/PHP/php-cgi.exe"
AddType application/x-httpd-php .php

<Directory "C:/PHP">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

我仍在等待有人解释第二个问题。

相关内容