Our recent deployment of the Joint Contact Community Forum required us to figure out how to get PHP 5 working in IIS 7.0. This was a fairly new and interesting concept so we’d like to share our experience and offer some of the steps we took to get PHP to work in IIS7. Our configuration is using PHP 5.2.5 so this article will be specific to this configuration.
Install IIS 7
The first step is to find a machine capable of running IIS 7.0. For those who don’t know, IIS 7.0 is available under Windows Server 2008 or Windows Vista (Ultimate or Business). In addition to supporting ASP and ASP.NET applications Microsoft has also introduced the ability for you to run non-Microsoft technologies like PHP pages (good for you Microsoft)! Since our company works with Microsoft technologies this was an added convenience as we didn’t have to install Apache to support our PHP application. To learn more about IIS 7.0 visit www.iis.net.
Enable FastCGI
Next, we need to enable FastCGI support. The IIS FastCGI support enables IIS to host normal CGI programs like PHP or Ruby On Rails. To configure this option choose Control Panel -> Programs and Features -> Turn Windows features on or off. To learn more about FastCGI, go here: http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/
Install/Configure PHP
The next step is to download and install PHP. You can get this from PHP’s webste at www.php.net. It is recommended that you install the non-thread-safe version for optimal performance. You can put the PHP folder anywhere, in our example we will assume that PHP is stored in C:\PHP.
After installing PHP, there are some important configurations needed in the php.ini file. This file is located at the root of your PHP directory, e.g. C:\PHP. There is a pre-configured file called php.ini-recommended, go ahead and open and save this file as php.ini. In php.ini, we will set the following values:
- fastcgi.impersonate = 1
- cgi.fix_pathinfo= 1
- cgi.force_redirect = 0
You will need to uncomment the values before setting them. (e.g. ;factcgi.impersonate =1 -> factcgi.impersonate=1)
Congfigure IIS to handle PHP
Next, we need to configure IIS to handle PHP requests. Open IIS Manager and select Handler Mappings. On the right, click on Add Module Mapping. Enter the following configurations:
- Enter *.php for Request path
- Select FastCGIModule in Module
- Enter C:\[path to YOUR PHP executable]\php-cgi.exe for Executable
- Enter PHP via FastCGI for Name
- Click OK
The dialog box appears asking if you want to create a FastCGI application for this executable. Click Yes.
That’s it! You’re done. Now test that php is working by creating a simple php file. Copy and paste the following code to a file and save as phpinfo.php.
<?php phpinfo(); ?>
Save the file in the C:\inetput\wwwroot directory. Open a browser and access the following URL http://localhost/phpinfo.php.
Related Links
http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis7/



You folks contributing here are very sharp. ,