Install and Configure PHP

Last updated: 2018-08-06 15:44:27

PDF

This document introduces the PHP configuration of Windows CVM. For more information, please see Installation of PHP versions above 5.3 and Installation of PHP 5.3 and earlier as needed.

Prerequisites

To configure PHP in Windows CVMs, you need to add and install IIS role. For more information, please see Installing and Configuring IIS.

Installation of PHP Versions above 5.3


For PHP versions above 5.3, the installer mode has been canceled, and the installation is only performed through zip file or debug pack. The following example shows the zip installation in Windows Server 2012 R2 environment.

Downloading File

  1. Download the PHP zip installer from the CVM (download URL: http://windows.php.net/download/).

    Note:
    You must select Non Thread Safe (NTS) x86 package when running under IIS. If you have to select x64 package for PHP in Windows Server 32bit (x64), you cannot select IIS. In this case, you can use Apache as an alternative option.

    Select the installer as shown below:


  2. The installation of PHP versions above 5.3 is dependent on Visual C++ Redistributable Update. Download and install VC Update Installer according to the name of downloaded PHP installer by referring to the relations as shown in the following table:

PHP Installer Name Download Link for Visual C++ Redistributable Installer
php-x.x.x-nts-Win32-VC14-x86.zip Visual C++ Redistributable for Visual Studio 2015
php-x.x.x-nts-Win32-VC11-x86.zip Visual C++ Redistributable for Visual Studio 2012 Update 4
php-x.x.x-nts-Win32-VC9-x86.zip Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)

If the downloaded PHP installer is as shown below:

then download the installer for VS 2015 version based on the relation indicated in the first row, and download and install the following two .exe files:

Installation and configuration

  1. Unzip the PHP zip installer (in this case, extract to C:\PHP), copy php.ini-production and rename it to php.ini, as shown below:

  2. Click Server Manager -> IIS; On the local IIS, right-click and select IIS Manager:

    Click on the host name (IP) on the left to go to the home page, and then double-click Handler Mappings:

    Click Add Module Mappings on the right, enter the following information in the pop-up box, and click OK to save:

    Note:
    If you are unable to select php-cgi.exe as the executable file, please change the filename extension of the selected file to .exe:

  3. Click the server IP on the left to go to the home page and double-click Default Documents:

    Click Add on the right to add a default document named index.php:

  4. Click the server IP on the left to go to the home page and double-click FastCGI Settings:

    Click Edit on the right, and select php.ini path in Monitor the Changes Made to File:

  5. Create a PHP file index.php under C:\inetpub\wwwroot and write the following:

    <?php
    phpinfo();
    ?>
    
  6. Visit http://localhost/index.php in the browser on CVM and check whether the environment has been configured successfully. The appearance of the following page indicates that the configuration has been completed successfully:

Installation of PHP 5.3 and earlier versions

Note:
PHP 5.3 and earlier versions are no longer available on the official download address http://windows.php.net/download/. To use these versions, download them locally and upload them to the CVM or search on the CVM network. For more information on uploading files, please see here.

  1. Open PHP installer in the CVM.

  2. Select IIS FastCGI in Web Server Setup, as shown below:

  3. Complete the installation of PHP under the guidance of installation interface.

  4. Create a PHP file hello.php under C:/inetpub/wwwroot, as shown below:

    The following content is written to the hello.php file:

    <?php
    echo "<title>Test Page</title>";
    echo "hello world";
    ?>
    
  5. Access the public network IP of Windows CVM via browser to check whether the environment configuration has been completed successfully. The appearance of the following page indicates that the configuration has been completed successfully: