Using FastCGI to Host PHP Applications on IIS 6.0

2016 年 9 月 17 日4750

Using FastCGI to Host PHP Applications on IIS 6.0

By

December 5, 2007

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:

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://http://www.zjjv.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:

http://http://www.zjjv.com///extensions/fastcgi

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:

Download and Install PHP

The FastCGI extension is fully compatible with the current official PHP 4.4.x and PHP 5.x distribution for Windows, available from http://http://www.zjjv.com///download. Since the FastCGI extension hosts and executes php processes in a single threaded manner, it is recommended that you download and install the non-thread-safe PHP build that is available for Windows. The non-thread-safe PHP build provides a performance boost from a lack of thread safety that is acceptable for a single-concurrency environment like FastCGI.

Configure the FastCGI Extension to Work with PHP

Once PHP is installed on Windows, you have two options to configure FastCGI: use the configuration script that is provided with the installation of the FastCGI extension, or perform all the configuration tasks manually by modifying IIS configuration settings and the fcgiext.ini file.

Configure the FastCGI Extension to Work with PHP by Using the Configuration Script

The configuration script with the name fcgconfig.js is provided with the installation of the FastCGI extension. It is located in %windir%\system32\inetsrv.

To configure the FastCGI extension to work with PHP:

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

Replace C:\PHP\php-cgi.exe with the path to php-cgi.exe if you installed to a directory other than C:\PHP.

Note: If you do not want to register the PHP extension to be processed by the FastCGI component on your entire server, and only want to register it for a specific Web site, add a "

0 0