Skip to content

Instantly share code, notes, and snippets.

@bombless
Last active July 29, 2025 02:47
Show Gist options
  • Select an option

  • Save bombless/e5d5e3a1101972a265fc17be777baa3f to your computer and use it in GitHub Desktop.

Select an option

Save bombless/e5d5e3a1101972a265fc17be777baa3f to your computer and use it in GitHub Desktop.
iis7安装fastcgi

iis url-rewrite模块下载: https://www.iis.net/downloads/microsoft/url-rewrite

英语x86 https://download.microsoft.com/download/D/8/1/D81E5DD6-1ABB-46B0-9B4B-21894E18B77F/rewrite_x86_en-US.msi

英语x64 https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi

中文x86 https://download.microsoft.com/download/D/8/1/D81E5DD6-1ABB-46B0-9B4B-21894E18B77F/rewrite_x86_zh-CN.msi

中文x64 https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_zh-CN.msi

https://chat.qwen.ai/s/4c856ce0-2e2f-4d7f-8dc5-013f98a06572?fev=0.0.166

用户权限需要配置IIS_IUSRS用户

这个错误说明IIS找不到PHP的FastCGI处理器。这是PHP环境配置问题。

解决步骤

1. 确认PHP已安装

# 在命令行检查PHP是否安装
php -v

如果没有安装PHP,需要先安装PHP。

2. 配置FastCGI(推荐方法)

方法一:通过IIS管理器配置

  1. 打开IIS管理器
  2. 点击服务器节点(不是网站节点)
  3. 双击"FastCGI设置"
  4. 点击"添加应用程序"
  5. 设置:
    • 完整路径: C:\php\php-cgi.exe(根据实际路径调整)
    • 参数: 留空或根据需要添加

方法二:手动修改applicationHost.config

文件位置:C:\Windows\System32\inetsrv\config\applicationHost.config

<system.webServer>/<fastCgi>节添加:

<fastCgi>
  <application fullPath="C:\php\php-cgi.exe" maxInstances="4" />
</fastCgi>

3. 简化web.config

使用最基本的配置先测试:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <customErrors mode="Off" />
  </system.web>
  
  <system.webServer>
    <httpErrors errorMode="Detailed" />
    <directoryBrowse enabled="false" />
    
    <handlers>
      <add name="PHP-FastCGI" path="*.php" verb="*" 
           modules="FastCgiModule" 
           scriptProcessor="C:\php\php-cgi.exe" 
           resourceType="Unspecified" />
    </handlers>
  </system.webServer>
</configuration>

4. 找到正确的PHP路径

检查常见安装路径:

C:\php\php-cgi.exe
C:\Program Files\PHP\v7.4\php-cgi.exe
C:\Program Files (x86)\PHP\v7.4\php-cgi.exe

或者查看已有的FastCGI配置:

在IIS管理器中查看"FastCGI设置"看是否已有配置。

5. 重启服务

iisreset
net stop w3svc
net start w3svc

如果PHP未安装

需要先安装PHP:

  1. 下载PHP for Windows: https://windows.php.net/download/
  2. 选择"Non Thread Safe"版本
  3. 解压到C:\php\
  4. 配置php.ini文件

你现在能确认PHP是否已正确安装在服务器上了吗?如果不确定,可以运行php -v命令检查。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment