安装常见问题

本章包括了安装 PHP 的常见问题。PHP 可以用于几乎任何操作系统(可能除了 OS X 之前的 MacOS 之外),以及几乎任何 web 服务器。

要安装 PHP,请按照 安装与配置一章中的指示进行。

  1. 为什么不应该在实际运作环境中的 Apache2 中使用线程化的 MPM?
  2. Unix/Windows:应该上哪儿去找我的 php.ini 文件?
  3. Unix:我安装了 PHP,但每次我打开一个页面时,只得到一条“Document Contains No Data”消息!这是怎么回事?
  4. Unix:我从 RPMS 安装了 PHP,但是 Apache 不处理 PHP 页面!这是怎么回事?
  5. Unix:我从 RPMS 安装了 PHP 3,但它没有把我需要的数据库支持编译进去!这是怎么回事?
  6. Unix:我给 Apache 加上了 FrontPage extensions 补丁,结果 PHP 突然不工作了。PHP 和 Apache FrontPage extensions 兼容吗?
  7. Unix/Windows:我已经安装了 PHP,但当我试着通过浏览器访问 PHP 脚本时,得到了一个空白页面。
  8. Unix/Windows:我已经安装了 PHP,但当我试着通过浏览器访问 PHP 脚本时,得到了一个服务器的 500 错误。
  9. 某些操作系统:我已经在不出错的情况下安装了 PHP,但当我试着启动 Apache 时得到了一个未定义符号错误: [mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress
  10. Windows:我已经安装了 PHP,但当我试着通过浏览器访问 PHP 脚本时,得到如下错误: cgi error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
  11. Windows:我已经照着所有的说明做了,但还是不能让 PHP 和 IIS 一起工作!
  12. 当在 IIS,PWS,OmniHTTPD 或者 Xitami 中以 CGI 方式运行 PHP 时,出现如下错误: Security Alert! PHP CGI cannot be accessed directly..
  13. 怎样得知我的 php.ini 是否被找到和应用了?似乎我做的修改都没有生效。
  14. 怎样将 PHP 目录加入到 Windows 路径 PATH中去?
  15. 怎样使 php.ini 文件在 Windows 下被 PHP 所用?
  16. 有可能使 PHP 运作于 Apache 的 content negotiation(MultiViews 选项)吗?
  17. PHP 是否仅限于处理 GET 和 POST 请求方法?
为什么不应该在实际运作环境中的 Apache2 中使用线程化的 MPM?

PHP 是粘合剂。它将几十种第三方的库粘合到一起来创建很酷的 web 应用,并通过很直观且易于学习的语言界面使其看上去好像一个整体。PHP 的灵活与强大依赖于底层平台的稳定与耐用。起码需要将一个可运作的操作系统,一个可运作的 web 服务器以及可运作的第三方库粘合起来。其中任何一方不运作了,PHP 都需要有方法来识别出问题并且快速解决。如果没有完全独立的执行线程,完全独立的内存单元和稳定的空间对付每个请求,那底层架构就太复杂以至于不稳定因素更容易进入到 PHP 系统中。

如果必须要用线程化的 MPM,看看 FastCGI 配置,使 PHP 运行于自己独立的内存空间中。

最后需要指出,不使用线程化 MPM 的警告在 Windows 系统中没那么强烈,因为 Windows 中的大多数库都理应在多线程下安全运行。

Unix/Windows:应该上哪儿去找我的 php.ini 文件?

UNIX 中默认在 /usr/local/lib目录中,也就是 <install-path>/lib。很多人会在编译时通过 --with-config-file-path标记来改变路径。例如可以将路径设为:

--with-config-file-path=/etc
然后从发行包中将 php.ini-dist拷贝为 /etc/php.ini并编辑它来作出想要的修改。

--with-config-file-scan-dir=PATH

Windows 中 php.ini 文件的默认路径在 Windows 目录下。如果使用的是 Apache 服务器,则会首先在 Apache 的安装目录中寻找 php.ini,例如 C:\Program Files\Apache Group\Apache。这样同一台机器上不同版本的 Apache 就可以有不同的 php.ini 文件。

参见 配置文件

Unix:我安装了 PHP,但每次我打开一个页面时,只得到一条"Document Contains No Data"消息!这是怎么回事?

这可能意味着 PHP 发生了某类错误而导致了 core dump。查看服务器的错误日志看看是不是这样,再用一个小的测试例子试着重现此问题。如果你会用"gdb"的话,那么在 bug 报告中提供回溯跟踪很有助于帮开发人员查明问题。如果你用 Apache 的模块方式使用 PHP,试着这么做:

  • 停止 httpd 进程

  • gdb httpd

  • 停止 httpd 进程

  • > run -X -f /path/to/httpd.conf

  • 然后在你的浏览器中访问导致错误的 URL

  • > run -X -f /path/to/httpd.conf

  • 如果你遇到 core dump,gdb 此时就会通知你

  • 输入:bt

  • 你应该在 bug 报告中包括回溯追踪记录。应该提交到 » https://bugs.php.net/

如果你的脚本使用了正则表达式函数( ereg()等),应该确认在编译 PHP 和 Apache 时使用了同一个正则表达式包。在 PHP 和 Apache 1.3.x 中应该自动就是这样。

Unix:我从 RPMS 安装了 PHP,但是 Apache 不处理 PHP 页面!这是怎么回事?

假定你的 Apache 和 PHP 都是从 RPM 包中安装的,你需要在 httpd.conf 文件中取消以下部分或所有行的注释,或者把它们添加到该文件中:

# Extra Modules
AddModule mod_php.c
AddModule mod_php3.c
AddModule mod_perl.c

# Extra Modules
LoadModule php_module         modules/mod_php.so
LoadModule php3_module        modules/libphp3.so     # for PHP 3
LoadModule php4_module        modules/libphp4.so     # for PHP 4
LoadModule perl_module        modules/libperl.so
并且把:
AddType application/x-httpd-php3 .php3    # for PHP 3
AddType application/x-httpd-php .php      # for PHP 4
添加到全局属性中,或者添加到你希望加入 PHP 支持的虚拟域中。

Unix:我从 RPMS 安装了 PHP 3,但它没有把我需要的数据库支持编译进去!这是怎么回事?

由于 PHP 3 构造的原因,不容易编译出一个完全灵活的 PHP RPM 包来。这个问题在 PHP 4 中解决了。对于 PHP 3 来说,我们目前建议你用 PHP 发行包中 INSTALL.REDHAT 文件中所描述的机制。如果你坚持要用 PHP 3 的 RPM 版本,请接着往下看。

为了简化安装 以及由于 RPMS 使用了 /usr/ 而不是标准的 /usr/local/ 目录来存放文件,制作 RPM 包的人设定 RPMS 不安装任何数据库支持。你需要告诉 RPM 说明文件,你想要支持哪个数据库以及你的数据库服务器最高层路径。

下面的例子解说了如何在用模块安装下的 Apache 中加入流行的 MySQL 数据库服务器支持的过程。

当然这些信息可以调整用于任何 PHP 支持的数据库服务器。本例中我们也假定你从 RPMS 中完整安装了 MySQL 和 Apache。

  • 先去掉 mod_php3:

    rpm -e mod_php3

  • 然后取得源文件的 rpm 包并安装它,而不是编译它。

    rpm -Uvh mod_php3-3.0.5-2.src.rpm

  • 接着编辑 /usr/src/redhat/SPECS/mod_php3.spec文件

    在 %build 一节加入你想要的数据库支持,以及路径。

    对应于 MySQL 你应该加入 --with-mysql=/usr 。则 %build 一节看上去将类似这样:

    ./configure --prefix=/usr \ --with-apxs=/usr/sbin/apxs \ --with-config-file-path=/usr/lib \ --enable-debug=no \ --enable-safe-mode \ --with-exec-dir=/usr/bin \ --with-mysql=/usr \ --with-system-regex

  • 一旦完成了这个修改,就这样建立二进制程序的 rpm 包:

    rpm -bb /usr/src/redhat/SPECS/mod_php3.spec

  • 然后安装 rpm

    rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm

确认重新启动了 Apache,这下你就有了用 RPM 安装的并且带 MySQL 支持的 PHP 3 了。注意按照 PHP 3 发行包中 INSTALL.REDHAT文件的说明来编译其实也许更容易一些。

Unix:我给 Apache 加上了 FrontPage extensions 补丁,结果 PHP 突然不工作了。PHP 和 Apache FrontPage extensions 兼容吗?

兼容的。PHP 可以和 FrontPage extensions 一起工作,问题是 FrontPage 补丁修改了几个 PHP 依赖的 Apache 构造。在 FrontPage 补丁安装之后之后重新编译 PHP(用"make clean ; make")可以解决此问题。

Unix/Windows:我已经安装了 PHP,但当我试着通过浏览器访问 PHP 脚本时,得到了一个空白页面。

用浏览器中的"查看源文件",你可能会发现能看到 PHP 脚本的源程序。这意味着 web 服务器没有把脚本发送给 PHP 解释。服务器配置在某处有问题,请对照 PHP 安装说明仔细检查服务器配置。

Unix/Windows:我已经安装了 PHP,但当我试着通过浏览器访问 PHP 脚本时,得到了一个服务器的 500 错误。

当服务器尝试运行 PHP 时出了错。要想看到有意义的错误信息,在命令行中转到 PHP 可执行程序(Windows 中是 php.exe)所在目录下并运行 php -i。如果 PHP 运行有任何问题,那么会显示相应的错误信息,这将给你下一步要做什么的线索。如果你得到满屏幕 HTML 代码( phpinfo()函数的输出)的话说明 PHP 本身工作正常,你的问题可能和你的服务器配置有关,要仔细检查。

某些操作系统:我已经在不出错的情况下安装了 PHP,但当我试着启动 Apache 时得到了一个未定义符号错误:
[mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress

这实际上和 PHP 没有关系,而和 MySQL 的客户端库有关。有的需要 --with-zlib ,有的不需要。这个问题也包括在 MySQL 的 FAQ 中。

Windows:我已经安装了 PHP,但当我试着通过浏览器访问 PHP 脚本时,得到如下错误:
cgi error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

这个错误信息意味着 PHP 根本就不能产生任何输出。要想看到有意义的错误信息,在命令行中转到 PHP 可执行程序(Windows 中是 php.exe)所在目录下并运行 php -i。如果 PHP 运行有任何问题,那么会显示相应的错误信息,这将给你下一步要做什么的线索。如果你得到满屏幕 HTML 代码( phpinfo()函数的输出)的话说明 PHP 本身工作正常。

一旦 PHP 在命令行中工作正常,试着通过浏览器再次访问脚本。如果还失败的话那可能是如下原因之一:

  • 文件权限问题,你的 PHP 脚本, php.exephp4ts.dllphp.ini 或任何你要加载的 PHP 扩展库是匿名 internet 用户 ISUR_<machinename>无权访问的。
  • 脚本文件不存在(或者有可能不在你以为的地方,注意 web 文档的目录)。注意在 IIS 中通过 Internet 服务管理器设定脚本映射时选中"检查文件是否存在"可以捕捉到此错误。这样一来如果脚本文件不存在的话服务器就会返回一个 404 错误信息。还有一个额外的好处就是 IIS 会基于 NTLanMan 权限来替你对脚本文件做任何所需要的认证。
Windows:我已经照着所有的说明做了,但还是不能让 PHP 和 IIS 一起工作!

确认需要运行 PHP 脚本的任何用户有权限运行 php.exe!IIS 使用了一个在安装 IIS 时添加的匿名用户,这个用户需要有访问 php.exe的权限。同样任何认证用户也需要执行 php.exe的权限。在 IIS4 中你还需要告诉它 PHP 是一个脚本引擎。此外,你可能还需要阅读 此常见问题

当在 IIS,PWS,OmniHTTPD 或者 Xitami 中以 CGI 方式运行 PHP 时,出现如下错误: Security Alert! PHP CGI cannot be accessed directly..

必须将 cgi.force_redirect选项设为 0。 默认值为 1,因此要确认此选项没有被注释掉(用 ;)。和其它选项一样,是在 php.ini 中设定的。

因为默认值是 1,因此你必须百分之百确认使用了正确的 php.ini 文件。详细信息请阅读 此常见问题

怎样得知我的 php.ini 是否被找到和应用了?似乎我做的修改都没有生效。

要确认你的 php.ini 被 PHP 使用了,调用 phpinfo(),在接近开头的位置有一项叫做 Configuration File (php.ini)。这里将告诉你 PHP 在哪里找到了 php.ini 并且是否使用了。如果只显示一个目录则 没有使用任何 php.ini 文件,你应将你的 php.ini 文件放到该目录中。如果 php.ini 包括在该路径中则它已被应用了。

如果 php.ini 被使用了并且你是以模块方式运行 PHP 的,确保在修改了 php.ini 之后重新启动你的 web server。

怎样将 PHP 目录加入到 Windows 路径 PATH中去?

在 Windows NT,2000,XP 和 2003 下:

  • 进入控制面板并打开"系统"图标(开始 -> 设置 -> 控制面板 -> 系统,Windows XP/2003 中是:开始 -> 控制面板 -> 系统)

  • 选择"高级"标签页

  • 点击"环境变量"按钮

  • 在"系统变量"栏中

  • 找到 Path 这一项(可能需要向下滚动才能找到)

  • 鼠标双击 Path 这一项

  • 在最后加入你的 PHP 目录,包括前面的";"(例如: ;C:\php

  • 点击"确定"并重新启动电脑

在 Windows 98/Me 中需要编辑 autoexec.bat文件:

  • 打开记事本(开始 -> 运行,然后输入 notepad 并点确定)

  • 打开 C:\autoexec.bat文件

  • 找到这么一行:PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;..... 并在最后加上 ;C:\php

  • 保存文件并重新启动电脑

Note: 记住在上述修改之后重新启动,以确保对 PATH的改变生效。

PHP 手册过去提倡把文件拷贝到 Windows 系统目录中去,这是因为该目录( C:\WindowsC:\WINNT,等等)默认就在系统路径中。但是把文件拷贝到 Windows 系统目录中这一方式早已不被提倡,还可能造成问题。

怎样使 php.ini 文件在 Windows 下被 PHP 所用?

有几种方法。如果使用 Apache,阅读专门的安装指示( Apache 1Apache 2),否则就必须设定 PHPRC环境变量:

在 Windows NT,2000,XP 和 2003 种:

  • 进入控制面板并打开"系统"图标(开始 -> 设置 -> 控制面板 -> 系统,Windows XP/2003 中是:开始 -> 控制面板 -> 系统)

  • 选择"高级"标签页

  • 点击"环境变量"按钮

  • 在"系统变量"栏中

  • 点击"新建"按钮并在"变量名"中输入"PHPRC",在"变量值"中输入 php.ini 文件所在的目录(例如: C:\php

  • 点击"确定"并重新启动电脑

在 Windows 98/Me 中需要编辑 autoexec.bat文件:

  • 打开记事本(开始 -> 运行,然后输入 notepad 并点确定)

  • 打开 C:\autoexec.bat文件

  • 在文件结尾处加入一行: set PHPRC=C:\php(将 C:\php替换为你的 php.ini 实际存在的目录)。注意路径中不能包含空格。例如将 PHP 安装到了 C:\Program Files\PHP中,你需要输入 C:\PROGRA~1\PHP替代之

  • 保存文件并重新启动电脑

有可能使 PHP 运作于 Apache 的 content negotiation(MultiViews 选项)吗?

如果到 PHP 文件的连接包含扩展名,一切都运行完美。本解答只针对到 PHP 文件的连接不包含扩展名时,而希望通过 content negotiation 来从不包含扩展名的 URL 来选择 PHP 文件的情况。在此种情况下,将 AddType application/x-httpd-php .php替换为:

# PHP 4
AddHandler php-script php
AddType text/html php

# PHP 5
AddHandler php5-script php
AddType text/html php
此方案对于 Apache 1 不适用,因为 PHP 模块不捕获 php-script

PHP 是否仅限于处理 GET 和 POST 请求方法?

不是,PHP 有可能处理任何请求方法,例如 CONNECT。适当的回应状态可以用 header()发送。如果仅需要处理 GET 和 POST 方法,可以通过如下的 Apache 配置实现:

<LimitExcept GET POST>
Deny from all
</LimitExcept>

User Contributed Notes

ssaxena at nriol dot com 12-Mar-2010 02:28
Here are my struggle to get PHP 5.2.12 working on Windows XP SP3, IIS 5.1 (Please note Win XP SP3 has issue of FastCGI)

1. Dowloaded installer and installed in C:\Program Files\PHP as ISAPI module

---->Did not work

Added php5isapi.dll in ISAPI Filter and added the extension .php in Home Dir->Configuration
(For every setting change restarted IIS on cmd->iisreset)

---->Did not work

(And the Google was pointing to the Fast CGI issue; Don't know why microsoft has MS-FAST ! )
Uninstalled the PHP and cleaned up the folders, PATH environment variable & PHPRC, the IIS settings and registry entries and shut down(restart is different from shut down) the system to make it very clean

2. Reinstalled the PHP in C:\PHP as ISAPI and did the same as above in IIS
(For every setting change restarted IIS on cmd->iisreset)

---->Did not work

Uninstalled and cleaned up same as above and took a breath to make sure what I am doing wrong.
Shutdown the system.

3. Unzipped the php-5.2.12-Win32.zip and did the same as above (this time manually PATH variable and security permission for the PHP folder and following settings)

short_open_tag = On
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
doc_root = "C:\Inetpub\wwwroot"
extension_dir = "C:\PHP\ext"
cgi.force_redirect = 0

---->Did not work

Uninstalled and cleaned up same as above
Shutdown the system.

4. Downloaded Microsoft Web Platform Installer 2.0 and select the PHP+Fast CGI+Windows Cache for PHP extension and Web Deployment Tools
restarted the system to take effect the settings

---->Did not work

Uninstalled and cleaned up same as above
Shutdown the system

5. Took the prev version of PHP php-5.2.4-Win32.zip unzip the folder and did the following changes:

short_open_tag = On
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
doc_root = "C:\Inetpub\wwwroot"
extension_dir = "C:\PHP\ext"
cgi.force_redirect = 0

set the security permission as IIS_machinename with full access to the C:\PHP folder

------->IT GOT WOKRING

Hope people would be aware of php-5.2.12 and would love the php-5.2.4
john dot calder at manukau dot ac dot nz 03-May-2008 10:19
WINDOWS 2003 and IIS.  BIG LESSON FOR ME was "don't mess with the optional components".
I had lots of trouble until I tried installing without asking for extras and then it was very smooth.
I have found no need to set up paths. 
I have found no need to configure IIS. 
I have found no need to change security on the PHP folder.

What works for me with Windows/IIS:

1.  You need to be logged-on as "administrator"

2.  Run  "php-5.2.6-win32-installer.msi"
Your ONLY action during this wizard is to select "IIS ISAPI" as the webserver.  Do NOT CHANGE anything else!  I am guessing that the optional extras apply only to Apache because after enabling them I see Apache-related error messages.

3.  Setup a test virtual directory as you would for an ASP or ASP.NET web app.  eg "phptest"
Then use notepad to create a test page eg "test.php"
<?php
phpinfo
();
?>

4.  In Internet Explorer, test with eg this address
http://localhost/phptest/test.php

IF this does not give you a beautiful page of details THEN start reading other advice on this page - especially helpful for me was the faq advice to test run "php.exe -i" from the command prompt.
charleslynch at xybersoftware dot com 17-Apr-2008 07:30
One final note to the message below if you are getting the message about not having rights to execute...You need to use IIS right click on the website and choose 'Properties/Home Directory' then on the 'Execute Permissions' combo box you need to choose 'Scripts only'...Click ok...another dialog may appear asking which directories to apply the action too...choose any directories that you intend on using php in and click ok...It should work now...
joerg at fenin dot de 02-Nov-2007 02:35
To limit HTTP Request Methods on the Apache server running PHP you should use mod_rewrite or mod_security instead of LimitExcept, to give you more control over the handling of such http errors.  Can go in .htaccess file or httpd.conf

# mod_rewrite
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST)$
  RewriteRule .* - [F,L]
</IfModule>

# mod_security
<IfModule mod_security.c>
  SecFilterSelective REQUEST_METHOD "!^(GET|HEAD|POST)$" "deny,log,status:403"
</IfModule>

You can use the php request method scanner at askapache to see exactly how your server deals with various request methods, and check that your server is configured properly.. 

http://www.askapache.com/online-tools/request-method-scanner/
scott at chaisson dot net 19-Sep-2007 09:18
Windows 2000 Server and IIS (SP4 and all patches):

After many frustrating hours of trying to figure out the install (again), It took a while, but here are a couple tips:

PHP working with IIS uses c:\winnt\php.ini

It doesn't matter what you set the path to, nor what you set the PHPRC environment variable to. After you get PHP running correctly in the installation folder (using php -i) copy the php.ini file into the c:\winnt folder.

Here's what worked for me:

- Add PHP path to System environment variable

- Add php5activescript.dll from http://snaps.php.net/ to the PHP folder, then Register it: "regsvr32 php5activescript.dll"

Set extension_dir and doc_root directives in PHP.INI:
  extension_dir = C:\WWW\PHP\ext
  doc_root = C:\WWW\Site
  cgi.force_redirect = 0

(the last cgi.force_redirect isn't required, but I like to set it anyway)

Copy the .INI file into WINNT folder

In IIS Manager, right-click "Default Web Site", Click "Home Directory",
  Click "Configuration", "Add" the ISAPI application:
    Executable: <your php install>\php5isapi.dll
    Extension: .php
    Limit to: GET,HEAD,POST
    Check: "Script Engine"
    Uncheck: "Check that file exists"

Finally: Set up an ISAPI filter:
  Click the "ISAPI Filters" tab,
  Filter Name: PHP
  Executable: <your php install>\php5isapi.dll

Notes: You don't have to set any of your folders as "Script source" folders. .PHP files aren't scripts, merely text files that require processing before being shipped off to the browser, which is what the ISAPI filter does.

Finally, working again.

Chase
christianfelix at laszlo dot com 16-Jul-2007 03:39
For Windows XP users

Just add php.ini to windows/system 32 and also save a copy in the setup folder e.g. c:/php/php.ini, c:/php5/php.ini,

You have to follow the suggestions, add to path, uncomment extensions and voila!!
Meiki67 skipthis at geemail 07-Jun-2007 04:41
Had a hard day to MSI install 5.2.3 on WinXP with MySQL. I use a drive substitution (subst drive: path - in my case subst d: c:\drive_d) and installed PHP in D:\PHP - which in reality is C:\DRIVE_D\PHP.  To make a long story short - only after (1) changing all substituted D:\ back to C:\DRIVE_D and (2) resolving all DOS short names to Win long names PHP started to work. The first one is clear - the substitution works only for the active console user - not for services or IUSR. For the second one I have no explanation, since DOS short names should work systemwide - maybe Win handles them correctly but PHP not ?

BTW <?php phpinfo(); ?> was of tremendeous help

Meiki
Curtis 18-May-2007 07:39
I have some additional troubleshooting tips for 53.7, which deals with getting a blank screen on your browser when running a PHP script.

In addition to server misconfiguration, it may also be that PHP isn't configured to output errors to the browser, which is the case if you or your host uses a more secure php.ini. If this is the case, you need to find out where errors are being logged to find out if any errors are preventing normal output from being delivered to the client.

If you have access to php.ini, check the 'display_errors' directive, which is, by default, located under the 'error_reporting' directive. It's helpful to have 'display_errors' on during debugging phases, but best to have it off in production environments.

Related functions: http://php.net/ini_set | http://php.net/error_reporting | http://php.net/error_log
knutw at sparhell dot no 06-Nov-2006 09:15
I recntly upgraded from PHP 5.1 to 5.2 on my Windows Server 2003 using IIS6. I selected CGI as before. My PHP folder is as always C:\Program Files\PHP. I also edited my brand new php.ini, enabling all my old extensions and recommended settings for IIS. I like not to keep my old config into a new version.

After upgrade, I just got blank pages in my browser, and the response status was 404 Not found.

I checked my installation twice, using this FAQ, but got no way.

Then I went to IIS Manager, Web Service Extensions. The php Service Extension was Allowed as it should. I deleted the Service Extension and added it. The old extension used short file names containing tilde (PROGRA~) character, but I don'?t know if that gas anything to do with the problem. Anyway, after allowing my" new" Service Extension, pointing to php-cgi.exe as before, mye web sites suddenly worked. So will revommend anyone with thos problem to delete and add the Servcie Extension. It didn't help re-allowing it, restarting IIS or the complete server.
13-Sep-2006 07:03
After setting the PHPRC environment variable, none of my PHP files would hit the preprocessor. The browser was just serving out PHP source code right there in the "view source."

The manual was telling me to set this var to "c:\php," but nothing was working. It's almost as if IIS/Win2000 wasn't reading my php.ini at all.

After I set that variable to "c:\php\php.ini," all of a sudden I was getting honest to goodness PHP pages working.
emzeperx at emzeper dot hu 01-Jan-2006 12:36
You do not have to restart the whole system make effect of changing the PATH env var. For me (sbs2003) worked automatically.
on older systems you can use

set $Path=%path%;c:\php

command to extend immediately the path var.
JUSTANOTHERUSER 14-Aug-2005 11:23
<LimitExcept GET POST>
Deny from all
</LimitExcept>

Does not work with Apache2+ & PHP5 . Apache Refuses to start
per dot fikse at ipj dot no 12-Jul-2005 01:22
Installing PHP 4 or 5 on Windows Server 2003 x64 results in http error 505. This is not a PHP bug. It is due to running a 32-bit ISAPI DLL under the 64-bit version of IIS 6, as documented here: http://support.microsoft.com/?id=895976

Solution: Flip the Metabase flag for Enable32bitAppOnWin64 as described in http://support.microsoft.com/?id=894435 ,
like this: CSCRIPT ADSUTIL.VBS SET W3SVC/AppPools/Enable32bitAppOnWin64 1

(Alternatively with full path: cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1)
barry dot fagin at usafa dot af dot mil 04-Jan-2005 09:22
Fixing 404 (file not found) errors with PHP 5.0.3 and IIS 6.0

IIS 6.0 is installed with security settings that don't permit dynamic content.  This means that even if all the hints in the FAQ are paid attention to (.ini modified correctly, security and permissions correct for IUSR_xxx user, etc), you still get 404 errors for all php files. 

To fix this:  IIS Manager -> expand local computer -> Web Services Extensions -> Add web service or extension -> .php, browse to c:\php\php-cgi.exe or wherever you had the php executable installed. That plus setting the doc_root in the .ini file solved the problem.

--BF
jeff_graham at datacenterservices dot net 01-Feb-2004 01:51
As stated within the note "jimo at mail dot azhsv dot com
29-Nov-2003 04:33
PHP 4 and IIS 6.0 (Windows Server 2003)," I found the same steps were requiered for installation of PhP 5 beta 3 on my Windows 2003 server (Standard Edition)
nigel dot salt at hotmail dot com 13-Dec-2003 05:00
Finally got IIS 5 and PHP 5 to talk. 

What worked for me was:

1) Set
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
W3SVC\Parameters\Script Map]
".php"="your path to php\\php.exe"

2) ensure there is not a php.ini in the windows system folder and that there is one wherever you've put PHP

3) edit php.ini and set cgi force redirect to 0 and cgi.rfc2616_headers = 1

4) Put the PHP scripts in their own folder underneath the inetpub root

5) Open the IIS console, right click your new php folder
In the Directory tab
 set application name to the name of the folder
 set executable and script as permission
 set application protection to low
Click configuration and check that .php is mapped to wherever you put
PHP

Restart IIS

Try a very simple PHP page and it should work

Nigel
jimo at mail dot azhsv dot com 29-Nov-2003 07:33
PHP 4 and IIS 6.0 (Windows Server 2003)

Had difficulty getting PHP 4.3.3 to work with Win2003 Ent Server for use with SquirrelMail.  Problem found and believed solved.  Appears to be something New with IIS 6.0 (More security by Micro$oft)  Was getting 404 error and php was not being run as a cgi even though it was in extensions and IIS user had rights to execute it. (php from command line operated correctly)

If you are installing on Windows Server 2003 (only have Enterprise Edition ? Not sure if this applies to standard edition), and you have done the normal procedures for inclusion of PHP scripts (either ISAPI or CGI) in IIS, you will still get a 404 error when attempting to execute those scripts even though IIS has rights and the extension points to the correct file.  To alleviate this problem, perform the following:

1.    Open a command prompt window
2.    Change to C:\windows\system32
3.    Execute the command:  cscript  iisext.vbs /AddFile c:\php\php.exe 1 php 0 php
4.    Execute the command:  cscript iisext.vbs /EnFile c:\php\php.exe
5.    To check for correct execution of the above,
6.    Execute the command:  cscript IisExt.vbs /ListFile ? the php extension should be listed

If you try just step 4 without step 3 you get an error that the file is not in the list (and won?t be there till you do step 3 above)

After this, IIS seems to like the php extension and work normally.

For additional reference, see the below 3 Micro$oft KB Articles:
HOWTO: Enable and Disable ISAPI Extensions and CGI Applications in IIS 6.0 (MS KB Article 328360)

HOWTO List Web Server Extensions and Extension Files in IIS 6.0 (MS KB Article 328505)

HOWTO Add and Remove Web Service Extension Files in IIS 6.0 (MS KB Article 328419)
peter dot mosinskisNOSPAM at csuci dot edu 06-Mar-2003 12:36
Running Win2K AS + IIS5.0 + PHP 4.3.1, I ran into a nasty problem that I mistakenly thought had to do with something in the php.ini configuration. When I would try to submit a form using the HTTP method GET it would work, but I would get a "404 Page Not Found" error using the POST method.

All my permissions were set correctly, the php.ini was configured correctly. It had to do with URLScan being installed on IIS (see below)

Page 404 File Not Found Error When Using POST method in PHP (and Perl, and otherwise)
-------------------------------------------

This is related to the Microsoft URLScan utility. If you have this problem, the IIS administrator has probably run the IIS Lockdown tool as well as configured URLScan to reject this type of HTTP method when sent in a URL. These tools are meant to enhance web server security.

URLScan configuration files can be found in the \WINNT\system32\inetsrv\urlscan folder on the web server. Specifically, the file to modify is urlscan.ini.

The changes to make are as follows:
1. Make sure UseAllowVerbs=1 under [options]
2. Under the [AllowVerbs] section, list your allowed HTTP methods to include:
    GET
    POST

For more information on the IIS Lockdown tool and URLScan, visit http://technet.microsoft.com
monroe at peoplego dot com 17-May-2002 10:32
INSTALLATION ON OPENBSD 3.1 VIA PORTS COLLECTION
Would have succeed but no mysql support.
I commented out the FLAVORS+= dbase filepro mysql mysql_bundled postgresql iodbc in the /usr/ports/www/php4/Makefile and in the configure options added 
--with-mysql=/usr/local   and it worked.

Good Luck