Tuesday, January 17, 2023

Using FastCGI to Host PHP Applications on IIS 6.0

Here is the article.

by Ruslan Yakushev

Introduction

The PHP programming language has been an important player in the Web Application space for many years. Even though PHP was not developed by Microsoft, supporting this technology is very important to us and so you can install it on any stand-alone IIS Server, and it's also built-in to our cloud-based Windows Azure Web Sites (WAWS) platform. This article explains how to use the Microsoft IIS FastCGI extension to set up and run PHP applications on Windows XP and Windows Server® 2003 operating systems.

What is FastCGI?

FastCGI is a standard protocol that allows the CGI executable files for application frameworks to interface with the Web server. It differs from the standard CGI protocol in that FastCGI reuses CGI processes for multiple requests, which provides a significant performance boost as compared to CGI. Support for IIS FastCGI enables IIS to host normal CGI programs like PHP or Ruby on Rails by using the FastCGI protocol, and to offer high performance and stability for production deployment of such application frameworks.

Using the IIS FastCGI support includes the following:

  • IIS Web server
  • IIS FastCGI extension
  • CGI program (such as php-cgi.exe)

The Web server dispatches HTTP requests to your application to the FastCGI component, which in turn launches the CGI program executable, and forwards the request for processing. Once the request is finished and the response is returned back to the server and sent to the client, the CGI process is reused for a subsequent request. This helps to avoid the high performance penalty of starting a new process for each request, which results in better performance and scalability in a production environment.

To learn more about the FastCGI protocol, see http://www.fastcgi.com/devkit/doc/fcgi-spec.html.

Install the FastCGI Extension for IIS 6.0 and IIS 5.1

You can download the FastCGI extension for 32-bit and 64-bit Windows XP and Windows Server 2003 here:

https://www.iis.net/downloads/microsoft/fastcgi-for-iis

When you run the FastCGI installer, it copies FastCGI-specific files to the %windir%\system32\inetsrv folder, and then registers and enables the FastCGI Web server extension. Of the files that the installer copies, note the following:

  • fcgiext.dll – This is the actual FastCGI handler that communicates with FastCGI-enabled processes for processing requests.
  • fcgiext.ini – This is the configuration file that contains the mapping of file extensions to FastCGI processes. It also contains the configuration of FastCGI process pools.
  • fcgiconfig.js – This configures the FastCGI extension. The script updates the fcgiext.ini file, modifies the IIS metabase and recycles the Web service application pools if necessary.

No comments:

Post a Comment