All Products
Search
Document Center

:How do I use IIS to build a PHP environment on a Windows instance?

Last Updated:Sep 09, 2024

This topic describes how to use Internet Information Services (IIS) to build a PHP environment on a Windows Elastic Compute Service (ECS) instance.

Note

Disclaimer: This topic may contain information about third-party products. The information is only for reference. Alibaba Cloud does not make any guarantee, express or implied, with respect to the performance and reliability of third-party products as well as the potential impacts of operations on the products.

Procedure

Note

This section describes how to use IIS to build a PHP environment on an ECS instance that runs Windows Server 2012. The operations may vary based on the version of Windows Server that runs on your ECS instance.

  1. Connect to the Windows ECS instance.

    For more information, see Connection method overview.

  2. Install IIS.

    For more information, see How to install IIS and FTP services on Windows instances.

    Important

    You must install .NET Framework 3.5 before you can install PHP.

    When you install the Web Server (IIS) role on the Windows ECS instance, expand Application Development and select CGI, as shown in the following figure. image

  3. Download a PHP installation package for Windows from the official PHP website. In this example, a PHP 5.2.17 installation package, such as php-5.2.17-nts-Win32-VC6-x86.zip, is downloaded.

    Note

    1. Download a PHP installation package whose name contains the "nts" string. PHP installation packages whose names contain the "nts" string are installation packages of Non-thread Safe (NTS) PHP versions.

    2. Before you install PHP on the Windows ECS instance, install the VC++ runtime libraries on which PHP depends on the instance.

  4. Decompress the PHP installation package to a specific directory.

  5. The first time you start Internet Information Services (IIS) Manager, the Internet Information Services (IIS) Manager dialog box appears. Select Do not show this message and click No in the dialog box.

  6. In the left-side navigation pane of the Internet Information Services (IIS) Manager window, right-click Sites and select Add Website. In the Add Website dialog box, configure parameters to add a website. In this example, the test website is added.

  7. To add a mapping for PHP, choose Sites > Website that you added in the previous step in the left-side navigation pane of the Internet Information Services (IIS) Manager window. Double-click Handler Mappings in the Home pane. Click Add Module Mapping in the Actions pane. In the Add Module Mapping dialog box, configure parameters to add information about a PHP module. Set the Request path parameter to *.php, the Module parameter to FastCgiModule, the Executable parameter to the path in which PHP is installed, and the Name parameter to a custom name and click OK. In the Add Module Mapping message, click Yes.

    Note

    In this example, a handler mapping for PHP to the test website is added.

    image

  8. Create a PHP webpage in the website root directory. In this example, the phpinfo page is created. Create a PHP file and add the following content to the file:

    <?php
    	phpinfo();
    ?>
  9. Access the test website to check whether the PHP webpage is displayed as expected.image

FAQ

What do I do if a 500 error occurs when I use IIS to debug PHP?

If you receive a 500 error when you use IIS to debug PHP, set the Identity parameter in the Application Pool Defaults dialog box to LocalSystem. In this example, Windows Server 2012 is used. Perform the following steps:

  1. In the left-side navigation pane of the Internet Information Services (IIS) Manager window, click Application Pools.

  2. Right-click a blank area in the application pool list and select Set Application Pool Defaults. 单击应用程序池

  3. In the Process Model section of the Application Pool Defaults dialog box, set the Identity parameter to LocalSystem. 修改标识

  4. Click OK.