大网数据广告活动
PHP 语言与运行手册

Windows 上与 IIS 安装

· 52CE 我爱测

Internet 信息服务 (IIS) 内置于 Windows 中。在 Windows Server 上,可以通过服务器管理器添加 IIS 角色。需要包含 CGI 角色功能。在 Windows 桌面上,必须通过控制面板的添加/删除程序添加 IIS。Microsoft 文档有» 关于启用 IIS 的详细说明。对于开发,也可以使用 » IIS/Express。

Windows 上与 IIS 安装

安装 IIS

Internet 信息服务 (IIS) 内置于 Windows 中。在 Windows Server 上,可以通过服务器管理器添加 IIS 角色。需要包含 CGI 角色功能。在 Windows 桌面上,必须通过控制面板的添加/删除程序添加 IIS。Microsoft 文档有» 关于启用 IIS 的详细说明。对于开发,也可以使用 » IIS/Express。

注意:

在 IIS 中使用 FastCGI 处理程序时,应安装 PHP 的非线程安全 (NTS) 版本。

使用 IIS 配置 PHP-CGI

在 IIS 管理器中,安装 FastCGI 模块并将 .php 的处理程序映射到 php-cgi.exe(而不是 php.exe)的路径

APPCMD 命令行工具可用于编写 IIS 配置脚本。

批处理脚本示例

示例 #1 命令行配置 IIS 和 PHP


@echo off

REM download .ZIP file of PHP build from http://windows.php.net/downloads/

REM path to directory into which PHP .ZIP file was decompressed (no trailing \)
set phppath=c:\php


REM Clear current PHP handlers
%windir%\system32\inetsrv\appcmd clear config /section:system.webServer/fastCGI
REM The following command will generate an error message if PHP is not installed. This can be ignored.
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /-[name='PHP_via_FastCGI']

REM Set up the PHP handler
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath='%phppath%\php-cgi.exe']
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='%phppath%\php-cgi.exe',resourceType='Unspecified']
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /accessPolicy:Read,Script

REM Configure FastCGI Variables
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /[fullPath='%phppath%\php-cgi.exe'].instanceMaxRequests:10000
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phppath%\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phppath%\php-cgi.exe'].environmentVariables.[name='PHPRC',value='%phppath%\php.ini']"

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。