All Products
Search
Document Center

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

Last Updated:Feb 29, 2024

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

Procedure

Note

In this example, Windows Server 2012 is used. Operations vary based on operating systems.

  1. Connect to the Windows instance.

    For more information, see Connection methods.

  2. Install IIS.

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

    Important

    .NET Framework 3.5 must be installed. Otherwise, PHP Manager cannot be installed.

  3. Install the Web Platform Installer.

    Important

    If your operating system is Windows Server 2008, you can only download a Web Platform Installer installation file from the Web Platform Installer page and then double-click the file to install the Web Platform Installer.

    1. In upper-right corner of the Server Manager window, choose Tools > Internet Information Services (IIS) Manager.

    2. In the Internet Information Services (IIS) Manager dialog box, click Yes. Microsoft Web Platform.png

    3. On the Web Platform Installer page, download the Web Platform Installer installation file. Then, install the Web Platform Installer. Web Platform Installer.png

      After the Web Platform Installer is installed, you can find it in the Management section of the Internet Information Services (IIS) Manager window. Web Platform Installer

  4. Install PHP Manager.

    • Method 1 (Recommended): Download a PHP Manager installation file from GitHub and then double-click the file to install PHP Manager.

    • Method 2: Use the Web Platform Installer to install PHP Manager.

      1. Start the Web Platform Installer and search for PHP Manager on the Applications tab.

      2. Find PHP Manager and click Add. Then, in the lower part of the Web Platform Installer window, click Install.

        After PHP Manager is installed, you can find it in the IIS section of the Internet Information Services (IIS) Manager window. PHP Manager installed

  5. Install PHP.

    1. Start the Web Platform Installer and search for the PHP version that you want to install on the Applications tab.

      In this example, PHP 7.2 is used. Perform the following operations to install PHP.

      Note

      You can install multiple PHP versions based on your needs.

      Install PHP 7

    2. Click Add and then click Install in the lower part of the Web Platform Installer window.

      If a page similar to the one in the following figure is displayed, it indicates that PHP is installed. PHP 7 installed

    3. Click Finish.

  6. Build a PHP environment.

    1. In the IIS section of the Internet Information Services (IIS) Manager window, double-click PHP Manager.

    2. Click Register new PHP version. In the dialog box that appears, select the php-cgi.exe file in the directory where the specified PHP version is installed and click OK to build a PHP environment. Select a PHP file

    3. (Optional) Click Change PHP version. In the Change PHP version dialog box, select a PHP version. Change the PHP version

    4. (Optional) Click Check phpinfo() and view the selected PHP version. View the PHP version

FAQ

A 500 error is reported when I use IIS to debug PHP. What do I do?

If you are prompted with a 500 error when you use IIS to debug PHP, set Identity 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. Click Application Pools

  3. In the Process Model section of the Application Pool Defaults dialog box, set Identity to LocalSystem. Set Identity

  4. Click OK.