How to use PHP runtime with IIS

This document briefly describes how to start using the PHP runtime library with Microsoft IIS 7.0 or later.

Install PHP 5.5

  1. Download the “Non Thread Safe” distributive from the download page of the PHP Web site and install it using the installer. If you use an x86 server you may download an older version of PHP, but if you use an x64 server you can use only PHP 5.5.

  2. Configure IIS to run PHP using the following instruction.

Note

Make sure that you DO NOT select the “WebDAV Publishing” component during configuration.

Enable SSL and SOAP in PHP

  1. Open the php.ini file in the directory where you have installed PHP.

  2. Find and uncomment the following lines:

extension_dir = "ext"
extension=php_soap.dll
extension=php_openssl.dll

Install “URL Rewrite”

Install the “URL Rewrite” Module from IIS Application Gallery if you use IIS 8 or IIS 8.5 or download and install it manually from http://www.iis.net/downloads/microsoft/url-rewrite

Create endpoint

Create an endpoint and configure URL mapping for each APS Application API.

  1. Create a web site on IIS which points to the folder where the endpoint’s files are located.

  2. Configure redirection for each APS service to the corresponding PHP script.

You may use the following example of Web.config which shows how to configure the redirection from service URLs “/applications” and “/organizations” to “applications.php” and “organizations.php” respectively:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
       <rewrite>
           <rules>
                <rule name="APS Application API" stopProcessing="true">
                    <match url="([_0-9a-zA-Z\-]+)(.*)" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{R:1}" pattern="^applications$" />
                        <add input="{R:1}" pattern="^organizations$" />
                    </conditions>
                    <action type="Rewrite" url="{R:1}.php{R:2}" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>