<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/install.windows.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'install.windows.iis.php',
    1 => 'Windows 上与 IIS 安装',
    2 => 'Windows 上与 IIS 安装',
  ),
  'up' => 
  array (
    0 => 'install.windows.php',
    1 => 'Windows 系统下的安装',
  ),
  'prev' => 
  array (
    0 => 'install.windows.apache2.php',
    1 => '在Windows系统上安装 Apache 2.x',
  ),
  'next' => 
  array (
    0 => 'install.windows.tools.php',
    1 => '用于安装 PHP 的第三方工具',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'install/windows/iis.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="install.windows.iis" class="sect1">
 <h2 class="title">Windows 上与 IIS 安装</h2>

 <div class="simplesect">
  <h3 class="title">安装 IIS</h3>
  <p class="simpara">
   Internet 信息服务 (IIS) 内置于 Windows 中。在 Windows Server 上，可以通过服务器管理器添加 IIS
   角色。需要包含 CGI 角色功能。在 Windows 桌面上，必须通过控制面板的添加/删除程序添加 IIS。Microsoft 文档有<a href="https://docs.microsoft.com/en-us/previous-versions/ms181052(v=vs.80)" class="link external">&raquo;&nbsp;关于启用 IIS
   的详细说明</a>。对于开发，也可以使用 <a href="https://www.microsoft.com/en-us/download/details.aspx?id=48264" class="link external">&raquo;&nbsp;IIS/Express</a>。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    在 IIS 中使用 FastCGI 处理程序时，应安装 PHP 的非线程安全 (NTS) 版本。
   </span>
  </p></blockquote>
 </div>
 <div class="simplesect">
  <h3 class="title">使用 IIS 配置 PHP-CGI</h3>

  <p class="simpara">
   在 IIS 管理器中，安装 FastCGI 模块并将 <code class="literal">.php</code> 的处理程序映射到
   <var class="filename">php-cgi.exe</var>（而不是 <var class="filename">php.exe</var>）的路径
  </p>

  <p class="simpara">
   <strong class="command">APPCMD</strong> 命令行工具可用于编写 IIS 配置脚本。
  </p>
 </div>
 <div class="simplesect">
  <h3 class="title">批处理脚本示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 命令行配置 IIS 和 PHP</strong></p>
   <div class="example-contents">
<div class="cdata"><pre>

@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=&#039;PHP_via_FastCGI&#039;]

REM Set up the PHP handler
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath=&#039;%phppath%\php-cgi.exe&#039;]
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /+[name=&#039;PHP_via_FastCGI&#039;,path=&#039;*.php&#039;,verb=&#039;*&#039;,modules=&#039;FastCgiModule&#039;,scriptProcessor=&#039;%phppath%\php-cgi.exe&#039;,resourceType=&#039;Unspecified&#039;]
%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=&#039;%phppath%\php-cgi.exe&#039;].instanceMaxRequests:10000
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+&quot;[fullPath=&#039;%phppath%\php-cgi.exe&#039;].environmentVariables.[name=&#039;PHP_FCGI_MAX_REQUESTS&#039;,value=&#039;10000&#039;]&quot;
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+&quot;[fullPath=&#039;%phppath%\php-cgi.exe&#039;].environmentVariables.[name=&#039;PHPRC&#039;,value=&#039;%phppath%\php.ini&#039;]&quot;
</pre></div>
   </div>

  </div>
 </div>
</div><?php manual_footer($setup); ?>