Sunday, July 18, 2010

How to install PHP 5.3.2 with FastCGI on IIS 5.1/6.0

Last week, I was required to install PHP 5.3.2 on a Windows XP machine with IIS 5.1. Installing Microsoft products have always been easier. For someone like me having technology background in Microsoft products, the installation was not a piece-of-cake.

So like always, I trusted my friend Google. Unfortunately, most of the guides describing the procedure were either not precise or obsolete. Most of them relied on php5isapi.dll which is no longer packaged with PHP 5.3.2. However, after spending some time, I was able to successfully install PHP on IIS. I am writing this entry to help those who are facing the same situation as I was last week.

In this post, I have assumed that you are a programmer and well acquainted with Microsoft Windows XP. I will be describing the installation procedure but will not be telling you how to open or edit a file. Lets start now.

Since php5isapi.dll is not included in PHP anymore, first you need to install FastCGI from Microsoft's official website.

To learn about FastCGI extension, please visit the following site:

The installation is pretty simple since it is from Microsoft!

Now you need to download latest version of PHP which is 5.3.2 from:

Please download Windows Binary VC9 x86 Non Thread Safe Zip Package. I am assuming here that you are using 32-bit architecture.

Extract the content of the package to C:\PHP. You can use a different path if you really need to. In this post, I will use this path everywhere so if you go for a different path, please use it everywhere.

Note that in C:\PHP folder, there is no php5isapi.dll file. However, we have php-cgi.exe file which will be useful for us later. There will be two php.ini files. One will be for use during development and one for use in production. I used the later one. So rename the production file php.ini-production to php.ini. Open this file and make sure that following entries appear like these. (Remove comments whenever required or change key values)

extension_dir = "C:\PHP\ext"
cgi.force_redirect = 0
fastcgi.impersonate = 1
fastcgi.logging = 0

Save and close the file. Please make sure that all files/folders exist as specified in the above entries.

Now go to Properties of My Computer->Advanced and set the system environment variable "Path" to ";c:\PHP\".

Once done, go to C:\Windows\System32\inetsrv folder and open file fcgiext.ini and add the following:



Restart your computer.

Once restarted, type "inetmgr" on Windows Run command.

View Properties of "Websites", open "Home Directory" tab and click on "Configuration" button.
Click "Add" and provide the following values:
1. "C:\Windows\System32\inetsrv\fcgiext.dll" to "Executable" field.
2. ".php" to "Extension" field.
3. "Get,Head,Post" to "Verbs- Limit to"
4. "Script engine" and "Check that file exists" checkboxes should be checked.

Now go to "Documents" tab and add "index.php" to the list of default documents.
Open notepad and enter a simple script:


Save it as "index.php". Make a virtual directory in IIS and copy "index.php" to your website. Please make sure that the settings you made for "Websites" earlier are propagated to this Website.

View "Properties" of the website you have just added in IIS and under "Virtual Directory" tab, set "Application Protection to "Low (IIS Process)". Restart IIS.

Now open your website in a browser and you should see a page like this:

I will try to add screen snapshots to this tutorial to make it more understabable.
Future extension to this post:
I will demonstrate how to install SugarCRM (Open Source CRM) on this platform alongwith SQL Server 2008.
Best of Luck!

No comments:

Post a Comment