Installing PHP on Windows Vista with IIS 7 and Fast CGI

 

Requirements
Download and install the latest service pack for Windows Vista (at the moment SP2, at least SP1 is required to run FastCGI).
http://www.microsoft.com/downloads/details.aspx?FamilyID=a4dd31d5-f907-4406-9012-a5c3199ea2b3&displaylang=en

Download the latest or required version of PHP recommended the Non thread safe version.
http://www.php.net/downloads.php

Get The latest update of FastCGI in case of Vista SP1 (Needed for running Drupal)
http://www.microsoft.com/downloads/details.aspx?FamilyID=19600729-8470-4956-a276-200450d814bd&DisplayLang=en
 
Enabling Internet Information Server
If you already have IIS running but needed to update the version first disable IIS and then enable it again for it to allow to run the latest updates.

- Start|Computer|Uninstall or change a program|Turn Windows features on or off
- Select Internet Information Service
- Select World Wide Web
- Select Programming toepassingen
- Select CGI
 Windows_features.JPG
This should enable IIS7 on your computer.
 
Setup of PHP

Start the installation of PHP
- Select default directory C:\Program Files\PHP\
- Select IIS FastCGI option
- Select the Extensions you need, (Multi Byte String functions, MySQL functions)
- Install

 
Check the installation/configuration

To check the installation start IIS and go the default website or a website you are already running.

- Start|Control Panel|Adminisrative Tools|Internet Information Services (IIS) Manager
- click the Handler Mappings and make sure PHP_via_FastCGI is displayed in the list.
- double klik on PHP_via_FastCGI klik on Module and verify if the option FastCgiModule is present.

 
Testing the setup

To test if IIS works with the Fastcgi PHP, create an empty file and paste the following code :

<?php phpinfo(); ?>

Store the file in your web directory (c:\inetpub\wwwroot\) as info.php or index.php at least with the .php extension.

try to reach the info.php page

http://localhost/info.php

you should be able to see the php configuration.

 
optimizing the php.ini

An extensive guide to configure the php.ini and IIS can be found at:

http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70

Set fastcgi.impersonate = 1. FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.

Set cgi.fix_pathinfo=1. cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's previous behavior was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not care what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting this to 1 will cause PHP CGI to fix its paths to conform to the spec

Set cgi.force_redirect = 0.

Set open_basedir to point to a folder or network path where the content of the web site(s) is located.

Set extension_dir to point to a location where PHP extensions reside. Typically, for PHP 5.2.X that would be set as extension_dir = "./ext"

Enable the required PHP extension by un-commenting corresponding lines, for example:

extension=php_mssql.dll
extension=php_mysql.dll