This topic describes how to use Internet Information Services (IIS) to build a PHP environment on a Windows Elastic Compute Service (ECS) instance.
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
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.
Connect to the Windows ECS instance.
For more information, see Connection method overview.
Install IIS.
For more information, see How to install IIS and FTP services on Windows instances.
ImportantYou 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.
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.
Note1. 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.
Decompress the PHP installation package to a specific directory.
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.
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.
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.
NoteIn this example, a handler mapping for PHP to the test website is added.
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(); ?>
Access the test website to check whether the PHP webpage is displayed as expected.
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:
In the left-side navigation pane of the Internet Information Services (IIS) Manager window, click Application Pools.
Right-click a blank area in the application pool list and select Set Application Pool Defaults.
In the Process Model section of the Application Pool Defaults dialog box, set the Identity parameter to
LocalSystem
.Click OK.