您想学习如何在 IIS 服务器上安装 PHP 吗? 在本教程中,我们将向您展示如何在 IIS 服务器上安装和配置 PHP。
• Windows 2012 R2
• Windows 2016
• Windows 2019
• PHP 7
硬件列表:
以下部分介绍用于创建此 Windows 教程的设备列表。
上面列出的每一件硬件都可以在亚马逊网站上找到。
窗口教程:
在此页上,我们提供对 Windows 教程列表的快速访问。
教程 IIS – 在 Windows 上安装 PHP
首先,我们需要访问 Windows的PHP网站。
查找并下载 PHP 的非线程安全 (NTS) 版本。

在我们的示例中,下载了以下文件:php-7.2.9-nts-Win32-VC15-x86.zip。
在 C 驱动器的根目录上创建名为 PHP 的目录。
提取 PHP 文件夹中的文件内容。

Windows 的 PHP 需要安装微软 Visual Studio 的特定版本。
在我们的示例中,我们下载了 PHP 包生成 VC15。
PHP 生成 VC 15 需要安装微软 Visual Studio 版本 2017。

下载并安装 微软视觉工作室版本 2017 x86.

完成 Visual Studio 安装后,我们需要将 PHP 目录添加到 PATH 环境变量中。
访问系统属性窗口。
访问”高级”选项卡并单击”环境变量”按钮。

选择 PATH 变量并单击”编辑”按钮。

将 PHP 目录添加到 PATH 变量值的末尾。

打开 Windows 资源管理器应用程序并访问 PHP 文件夹。
找到名为 PHP 的文件。INI 生产。

重命名 PHP。INI 生产到 PHP。Ini
编辑名为 PHP 的文件。Ini。
以下是原始文件,在我们的配置之前:
这是我们配置后的文件。
请记住,您的时区文件可能与我的文件不一样。
测试 PHP 安装。
打开 DOS 命令提示符并输入以下命令。
祝贺!在 Windows 服务器上安装了 PHP。
教程 – IIS 在 Windows 上安装
打开服务器管理器应用程序。
访问”管理”菜单并单击”添加角色和功能”。

访问服务器角色屏幕,选择 Web 服务器 (IIS) 选项,然后单击”下一步”按钮。

在以下屏幕上,单击”添加功能”按钮。

在 IIS 服务屏幕上,选择 CGI 选项并完成安装。

IIS 服务器安装在您的计算机上,但我们仍然需要配置 PHP 集成。
打开 IIS 管理器应用程序并访问处理程序映射选项。

在屏幕右侧,选择名为”添加模块映射”的选项。
在模块映射屏幕上,您必须输入以下信息:

单击名为:请求限制的按钮。
选择”文件”或”文件夹”选项,然后单击”确定”按钮。

单击”确定”按钮。
如果显示以下消息,请单击”是”按钮。

现在,我们需要将 IIS 配置为接受索引.php作为默认页面。
打开 IIS 管理器应用程序并访问默认文档选项。

在屏幕右侧,选择名为”添加…
在”添加默认文档”窗口中,您必须输入以下信息:

要完成安装,您需要重新启动 IIS 服务。
右键单击屏幕左上角的服务器名称,然后选择”停止”选项。

右键单击屏幕左上角的服务器名称,然后选择”开始”选项。

祝贺! 您已经安装了 PHP 在 Windows 服务器上。
IIS 服务器现在支持 PHP 的使用。
在 Windows IIS 上测试 PHP 安装
打开记事本应用程序并创建名为”测试”的文档.php
此文档应放在 WWWROOT 文件夹中。
打开浏览器并输入 IIS Web 服务器的 IP 地址加上/测试.php
在我们的示例中,浏览器中输入了以下 URL:
• http://35.162.85.57/test.php
应提供以下内容。

IIS 上的 PHP 安装已成功测试。