Thursday, January 13, 2011

How to host php on IIS 7.5

Php application can be hosted on IIS web server by using FastCGI Module that can be found in IIS. Here I am using Windows 7 as my IIS web server. Same is for server 2008 R2. Remember R2 has IIS ver7.5.

First you  need to install IIS in your server, make sure that you have installed CGI feature while installation.

addorremoveCGI
Now you need to Install and Configure the php to run for IIS.
You may go to http://windows.php.net/download/ and download the php msi file for windows (VC9 x86 Non Thread Safe).


At the time of writing, Version 5.3.5 is the latest.  I have copied the files to the network, you can download them from file://bpsnt04/transfer/Setups/PHP/php-5.3.5-nts-Win32-VC9-x86.msi.

Run the installer, when ask for the destination folder change it to c:\php














Select IIS FastCGI from the Web Server Setup screen.

















Make the following changes to c:\php\php.ini
set fastcgi.impersonate = 1
set cgi.force_redirect=0
set cgi.fix=pathinfo=0

Create a new file named c:\inetpub\wwwroot\phpinfo.php with the contents as:
<?php
    phpinfo();
?>

If the php is installed correctly the url http://localhost/phpinfo.php will show the page below.











Additional Resources:
Phil's Blog
Microsoft Technet

No comments:

Post a Comment