我有 Win XP SP3 并安装了 IIS7.5 Express 并希望在其上运行 PHP。
我能够在服务器上运行简单的 HTML 代码,我能够通过运行 iisservices.exe 来启动和停止服务器,但我无法在其上运行 php 脚本。
如果我有以下 PHP 文件:
<? php
echo "hello world";
?>
<html>HI</html>
输出为
HI
但 PHP 脚本不运行。我已按照本文中描述的步骤安装 PHP:
http://learn.iis.net/page.aspx/724/install-and-configure-php/
但不能从第 10 步开始,因为 IIS Express 没有 IIS 管理控制台 MMC 管理单元。
如何配置 IIS Express 以运行 PHP?
最佳答案
假设您已经在 the article you linked to 中执行了步骤 1 - 9并将您的 PHP 文件提取到 c:\php
然后使用 cmd.exe
完成以下步骤命令提示符:
首先,我们需要配置 IIS Express 并为 PHP 设置处理程序
cd "\Program Files\IIS Express"
appcmd 设置配置 -section:system.webServer/fastCgi/+"[fullPath='C:\PHP\php-cgi.exe',arguments='',maxInstances='4',idleTimeout='300',activityTimeout=' 30',requestTimeout='90',queueLength='1000',instanceMaxRequests='200',protocol='NamedPipe',flushNamedPipe='False',rapidFailsPerMinute='10']"/commit:apphost
appcmd 设置配置 -section:system.webServer/handlers/+"[name='PHP-FastCGI',path='*.php',modules='FastCgiModule',verb='*', scriptProcessor='c:\php\php-cgi.exe']"/commit:apphost
假设您的 PHP 网站位于 c:\MyPHPWeb
我们在 IIS Express 中创建一个站点来监听 http://localhost:32701
:
appcmd 添加站点/name:"MyPHPApp"/bindings:http/*:32701:/physicalPath:"c:\MyPHPWeb"
接下来启动站点:
iisexpress.exe/site:MyPHPApp
最后浏览到您的 PHP 页面:
http://localhost:32701/test.php
关于iis-7.5 - 如何在 IIS7.5 Express 上运行 PHP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7080374/