Configure FastCGI to Host PHP from IIS 5.x and 6.x

I want to tell everybody that I am back again after last post from Jan 2011. MGe is lost after the Celebrating the Chinese New Year(I am Chinese, 🙂 ), and it is very sad that 2 relative passed away during the past week. 🙁

Somehow, I will continue sharing my post from here, :-).

Today, I want to guide my reader on how to configure PHP FastCGI for IIS 5.x and 6.x.

Prerequisite,
i) IIS5.x or 6.x installed.
ii) PHP installed.

Step:
Install FastCGI extension,
1. Download the extension from http://www.iis.net/extensions/fastcgi.
2. Install it and you will see it is installed to C:\Windows\System32\inetsrv folder.

Apply FastCGI extension,
i) Configure through command,
Run the follow command,

cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe"

ii) Manually Configure it.
1) Run inetmgr.
2) Right click Web Site and select properties.
3) Click on Home Directory tab.
4) Click on the Configure button.
5) Click on the Add button.
6) In the “Add/Edit Application Extension Mapping”, add the following information,
Executable: C:\Windows\System32\inetsrv\fcgiext.dll
Extension: .php
Verbs: Limit to GET, HEAD, POST
7) Click OK.

Modify the fcgiext.ini file,
1) Add the following information to the fcgiext.ini file,
[Types]
php=PHP
[PHP]
ExePath=C:\PHP\php-cgi.exe

Set the optimal setting for FastCGI,
Set the following value to php.ini,
fastcgi.impersonate = 1
cgi.fix_pathinfo = 1
cgi.force_redirect = 0

Set the following value to fcgiext.ini, run the following script.

cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000

Using ASP.Net MVC with different IIS

ASP.Net MVC is ASP.Net Modeling view controller where used to manage information and notify obeservers when that information changes.

To setting up ASP.Net MVC, you could setting it through IIS 6.0 or IIS 7.x.

  • IIS 7.x (integrated mode) – No special setting needed.
  • IIS 7.x (classic mode) – some setting needed to apply.
  • IIS 6.x or below – some setting needed to apply.

The setting needed as mentioned above actually is referring to creating the wildcard script map.

If you don’t want to use the URL mapping, you may actually ignore the setting as said, however if you want to use the mapping setting, you may refer as detail below.

IIS 7.0 with classic mode:

1.  Open IIS 7.0, select your application in the Connections window.
2. Make sure that the Features view is selected.
3. Double-click the Handler Mappings button.
4. Click the Add Wildcard Script Map link.

5. Enter the path to the aspnet_isapi.dll file (You can copy this path from the PageHandlerFactory script map)
6. Enter the name MVC.
7. Click the OK button.

IIS 6.0 or below:

1.  Right-click a website and select Properties.
2. Select the Home Directory tab.
3. Click the Configuration button.
4. Select the Mappings tab.
5. Click the Insert button.

6. Paste the path to the aspnet_isapi.dll into the Executable field (you can copy this path from the script map for .aspx files).
7. Uncheck the checkbox labeled Verify that file exists.
8. Click the OK button.