Turbo-charge your PHP applications with IIS FastCGI Technical Preview 2

After 3 months of community feedback and development, the FastCGI Techical Preview 2 has just been released! 

Before I jump into the juicy details, I want to thank everyone who has tried out the original release, and given us bug and feature feedback on the FastCGI forums.  This has been incredibly valuable in driving the feature forward, and I look forward to more of it as we move towards FastCGI beta (more on this later in the post).

*******************************
UPDATE:
- 2/10/2007: The Windows-optimized PHP 5.2.1 is now available from www.php.net/downloads.  Learn more about it here.
- 2/18/2007: Instructions on how to run Ruby on Rails with IIS FastCGI TP2 have been published.
*******************************

First things first

The FastCGI Technical Preview 2 release is an update for the first ever release of Microsoft IIS FastCGI feature in October 2006, providing a platform for high-performance and reliable way to run application frameworks like PHP on IIS (see my other posts about FastCGI and PHP). 

It is now available from the FastCGI main page on www.iis.net, with the following packages:
  1. FastCGI for IIS 5.x / IIS 6.0 - for Windows XP, and Windows Server 2003
  2. FastCGI for IIS 7 - for Windows Vista (RC1+), and Windows Server codenamed "Longhorn"
This release supports both 32-bit and 64-bit operating systems, so be sure to download the appropriate flavor of the package for your operating system.  The 64-bit package will work "out of the box" in both native 64-bit and 32-bit WOW64 IIS application pools on your 64-bit Windows OS, so you dont need to worry about any additional configuration.

FastCGI Tech Preview 2 is fully compatible with PHP 5.2, currently available from www.php.net/downloads.  You can install the FastCGI package and configure it to work with PHP by following the updated instructions in the updated Using IIS FastCGI with PHP article.  It should also work with PHP 4, although we havent extensively tested it, so if you run into any issues, please report them on the Forums.  

So, what am I getting?

The original technical preview release from October 30th of last year provided basic FastCGI functionality for running PHP applications.  Technical Preview 2 contains the following bug fixes and enhancements:
  1. Native support for 64 bit Windows operating systems.  The 64-bit packages provide full installation support for 64-bit OS, and enable both native 64-bit and 32-bit WOW64-based IIS applications.  The FastCGI application, such as PHP, can be either 32 bit or 64 bit.
  2. Additional server variables used by PHP and other FastCGI frameworks.  These include DOCUMENT_ROOT, REQUEST_URI, and SCRIPT_FILENAME.
  3. Support for PHP's fcgi.impersonate.  This enables PHP applications on Windows to impersonate the authenticated user making the request, enabling the PHP scripts to execute as that user instead of the identity of the IIS worker process.
  4. Improved error handling.  Added a number of error messages for common error conditions such as miconfiguration.  This is primarily done in the IIS7 package version.  Also, provided proper handling for FastCGI application errors, such as PHP script errors. 
  5. Improved FastCGI application process management.  The FastCGI component is now resilient to shutting down or killing the IIS worker process, or stopping the IIS service, making sure to terminate the child FastCGI application processes.  This means that you should no longer see orphaned php-cgi.exe processes when you do any of the things above.
  6. Improved timeouts.  Several changes to make the timeouts more flexible / correct, including the added the activityTimeout setting, which insures that the child FastCGI process remains responsive.  Also added the idleTimeout setting, which controls how long the process can be idle before its terminated,
  7. Enabled the TCP transport mechanism.  This provides support for TCP-based FastCGI application implementations.
  8. Removed the response entity-body, and request POST entity-body size limitations.  Previously, internal constraints limited this to 1 Mb each.
  9. Support for passing command line arguments to FastCGI application processes.  Allows FastCGI applications that require command line arguments to be specified to be used with the FastCGI feature.
  10. Experimental Ruby support.  More on this including setup instructions in the next post!

Look to the next post for more details on the configuration options, and advanced functionality, including how to set up Ruby with FastCGI on IIS.

Installation

In order to use the FastCGI package, do the following:

  1. Download the appropriate FastCGI TP2 package for your IIS version (IIS6 vs. IIS7) and OS bitness (32-bit vs. 64-bit)
  2. Unzip it to a local directory on your machine
  3. Use fcgisetup.js (IIS6) or fcgisetup.exe (IIS7) to install it:

    IIS6: cscript fcgisetup.js /install
    IIS7: fcgisetup.exe /install

    Note that the TP2 installation automatically replaces the TP1 installation if present.  It also does not require TP1 to be installed.
  4. Then, configure FastCGI TP2 with your scripting environment, like PHP, for example:

    IIS6: cscript fcgisetup.js /r /add c:\php\php-cgi.exe php  
    IIS7: fcgisetup.exe /add c:\php\php-cgi.exe php

This is the short of it.  Please read the detailed how-to in the Use PHP with FastCGI article.  If you need last minute reference, the instructions are also available in the included "readme.txt" file, and from the fcgisetup installer as command line help.

What's next? The FastCGI roadmap

The Technical Preview 2 release is still in the tech preview stage, and as such is not meant for production environments.  It is an opportunity for us to get the fixes out to the community for evaluation, and gather more feedback as we move forward to a well-tested, stable beta release suitable for production environments.

We are hoping to be ready for the Beta release for both IIS6 and IIS7 platforms sometime around April.  This is currently tentative, and since our first priority right now is getting IIS7 ready for primetime in Longhorn Server, plans may change.  Keep watching the FastCGI forums and this blog for more news as time goes on.

Another incredibly exciting event is the anticipated arrival of PHP 5.2.1 (you can get the dev builds right now from www.php.net), which will contain the majority of Zend's core PHP fixes designed to significantly improve its performance on Windows.  Combined with the IIS FastCGI feature, this should provide unparallelled PHP performance on the Windows / IIS platform.  As soon as this is available, be sure to grab it - I will also post some performance numbers to show it off.

Now, go download the FastCGI Tech Preview and let me know how it goes.  You can get support, and report issues on the IIS6 FastCGI forums and the IIS7 FastCGI forums.  Watch my blog for more details over the next week ...

We are all looking forward to your feedback!
Published 31 January 07 11:55 by Mike Volodarsky
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Peter Boling said on January 31, 2007 12:49 PM:
I am excited to hear about the "experimental ruby support"! This is very good news!
# Dominic Ryan said on January 31, 2007 2:13 PM:
This is great! Have two questions though that I can't seem to find answers for anywhere; 1) All the talk with this FastCGI module has been about PHP on IIS. The "experimental ruby support" line has me wondering, will there be any support for any other frameworks such as Python or Perl? 2) Any idea under which license this FastCGI module will be released once it is production ready?
# Mike Volodarsky said on January 31, 2007 2:40 PM:

The FastCGI project has a strong PHP focus, as part of our effort together with Zend to make PHP rock on Windows / IIS.  

But, that said, the FastCGI feature is a platform feature for running FastCGI compliant applications, so our goal is to make sure it supports the popular frameworks like Python, Perl, Ruby, etc by RTM.  There are a few issues we have found with each of these frameworks that currently impact our ability to run them, but hopefully we will get there.

Specifically for Ruby, Tech Preview 2 contains the "experimental support" necessary to get basic Ruby functionality.  I will be posting instructions shortly on how to set it up.  We are looking forward to community feedback, just like we got for PHP for the initial FastCGI release, to help us get more solid support for Ruby for beta.

# Kevin said on February 1, 2007 6:42 AM:
Awesome work!
# Kevin said on February 2, 2007 7:09 AM:
Your link: "Using IIS FastCGI with PHP article" Is broken. Please fix.
# Mike Volodarsky said on February 2, 2007 10:36 AM:

Kevin, thanks for the heads up!  Fixed the link.

# Mike Volodarsky said on February 5, 2007 5:03 PM:
A known issue with FastCGI TP2 has been found, and we are in the process of making the updated bits downloadable. Please re-download the package as soon as they become available. Track the progress of this issue at http://forums.iis.net/1564919/ShowThread.aspx#1564919. Thanks, Mike
# Mike Volodarsky said on February 6, 2007 8:09 PM:

The downloads have been updated with the fix.  Please let me know if you encounter other issues while using the new package.

# RvdH said on February 8, 2007 12:06 AM:

Is it just me, or am i missing something?

The documentation is missing, at least install instructions are.

Do i need TP1 before i can upgrade TP2?

TP2's fgiconfig program (running it with /h switch) refers to fcgisetup which is not available within the

FastCGI Technical Preview 2 download.

# Mike Volodarsky said on February 8, 2007 9:52 AM:

RvdH,

You dont need TP1 in order to install TP2, and TP2 will install over TP1 without a problem. Here is where you can find instructions on how to install:

1) Inside readme.txt included with the package
2) In the detailed how-to article for setting up PHP with FastCGI TP2, also linked above - http://www.iis.net/default.aspx?tabid=2&subtabid=25&i=1345

I also added the instructions to the blog post for additional discoverability.

Thanks, Mike

# Mike Volodarsky said on February 8, 2007 4:55 PM:

Thanks for the heads up.  We have been having some trouble with the website ... what you are seeing in the amd64 package is what would be expected for the x86 as well, with the exception of the amd64 subfolder.  Let me look into it ...

# Mike Volodarsky said on February 13, 2007 8:07 AM:

Quick update, the IIS6 x86 FastCGI download has been fixed and now contains the full package.  Sorry for the troubles.

# Sergey Nosenko said on February 16, 2007 4:19 AM:
What about FastCGI and Perl? I could not get it working. :(
# Mike Volodarsky said on February 19, 2007 11:43 AM:
I just posted the Ruby on Rails instructions for the IIS FastCGI TP2 on http://mvolo.com/blogs/serverside/archive/2007/02/18/10-steps-to-get-Ruby-on-Rails-running-on-Windows-with-IIS-FastCGI.aspx.

Check them out, and let me know if they work for you ...
# Edin Kadribasic said on February 19, 2007 4:25 PM:
Congratulations on great work. People will not stop bothering you until it is possible to use PATH_INFO in PHP for "nice" urls. Some pointers on how others have attempted to solve that particular issue at http://forums.iis.net/1585757/ShowThread.aspx#1585757
# Mike Volodarsky said on February 20, 2007 9:03 AM:

Hi Edin,

Thanks for posting ... I saw the IIS.NET thread on PATH_INFO, will look into it ...

# James stembridge said on March 29, 2007 4:00 AM:
Is any information on using the TCP transport mechanism available? I'd really like to get this working to improve performance of a python based cgi we're using.
# Tim said on April 16, 2007 3:04 AM:
I keep getting a: FastCGI Handler Extension Error 0x80070005 occurred processing request. Access is denied. Permissions though seem fine. IIS_USR on the root folder and permissions for SYSTEM account on the c:\php\ folder. Anyone can help?
# Mike Volodarsky said on April 16, 2007 9:03 PM:

Tim,

Is your application pool running as SYSTEM?  That is a very bad idea - you should leave it running as Network Service (default).  In that case, you have to give Network Service rights to the PHP directory.

You already have given the anonymous account rights to the PHP scripts you are accessing, which is good (just confirm that IIS_IUSR is your anonymous account).  FastCGI will always impersonate the authenticated user, like ASP, if you are using anonymous authentication.  Make sure you have anonymous authentication enabled just in case.

If this doesnt work, then get Process Explorer and monitor the registry / file accesses from the WP, to see what exactly fails.  It can also be that PHP.EXE is exiting with access denied - you can confirm this by checking whether PHP.EXE actually starts up on a request, and monitoring its accesses with Process Explorer to see what it fails on.

Thanks,

Mike

# Arthur said on April 19, 2007 5:41 AM:
If you want the fcgi handler to use the anonymous user credentials to access the .php files in your wwwroot, you have to make sure you have the following line in your php.ini: fastcgi.impersonate = 1 If this line is set to 0, impersonation will not take place. Instead the application pool identity (system, in your case) will be used.
# Amber said on April 22, 2007 9:25 PM:

Does IIS FastCGI handler support connecting to more than one remote instance (via TCP/IP)of the same application to achieve some load balancing magic, and does it support session affinity?

Amber, best regards!

guxiaobo1982@hotmail.com

# Mike Volodarsky said on April 24, 2007 9:54 AM:

Amber,

By default, each FastCGI application pool contains up to 4 child processes (and you can configure it to have any number you want, to have them spun up as needed).  When the first process is busy with a request, the second one is chosen to process the next one, and so on, so you get load balancing automatically due to the fact that only one request can be processing in each child process at any given time.

We do not support affinity, so its impossible to have process state for a client since his requests could end up in different processes.  Is this a critical scenario for you?

Thanks,

Mike

# ServerSide said on May 29, 2007 4:01 PM:
Ever since the original release of FastCGI Tech Preview 1 , and the Microsoft/Zend collaboration announcement
# Mike Volodarsky's ServerSide said on October 9, 2007 1:57 PM:

Everybody knows that IIS FastCGI is a great way to run PHP applications on IIS. So, if you are looking

# Mike Volodarsky's ServerSide said on October 9, 2007 2:02 PM:

Everybody knows that IIS FastCGI is a great way to run PHP applications on IIS. We've been making great strides at delivering a solid production experience for hosting PHP on IIS, for both IIS7 on Windows Vista/Windows Server 2008 and IIS6 / IIS5.1 on

# Mike Volodarsky's ServerSide said on November 12, 2007 3:28 PM:

Right as I was about to go home, one of our developers comes in to tell me some good news about our new IIS7 FastCGI module. So, I figure I would shed some light on our recent work to improve hosting PHP (yes, you read right, PHP) applications on Windows/IIS

# Mike Volodarsky's ServerSide said on November 13, 2007 5:38 PM:
Just over a year after the we first announced the FastCGI (see the first ever blog post about it: http://mvolo.com/blogs/serverside/archive/2006/09/29/Making-PHP-rock-on-Windows_2F00_IIS.aspx
# que0x said on January 2, 2008 8:29 AM:
FastCGI on IIS6 is doing well , please check http://blahblah.webunusual.com/index.php/2008/01/01/x64-fashioned-speed-iis-on-x64-php-and-fastcgi/
# robert said on June 2, 2008 5:17 PM:
PHP and IIS surely will be a development framework, FastCGI is great

Leave a Comment

(required) 
(optional)
(required) 
Enter the code you see below


About Mike Volodarsky

For the past 5 years, I was the core Program Manager for Microsoft ASP.NET 2.0 and IIS 7.0 products. I drove the design and development of the IIS 7.0 web server core, the IIS FastCGI support, the AppCmd command line tool, the ASP.NET Integrated pipeline, and other special projects around server security, performance, and scalability. Now, I am working on my own on cutting edge web server tech on top of the Microsoft IIS platform, and continue blogging about it here.

About me



For the past 5 years, I was the core server Program Manager for the IIS 7.0 and ASP.NET 2.0 products at Microsoft.
Now, I work on advanced web server tech using IIS 7.0, .NET, and Windows Server 2008 and write about it in this blog.

View Michael Volodarsky's profile on LinkedIn

Writings



TechNet Magazine
>Top 10 Performance Improvements in IIS 7.0

MSDN Magazine
>IIS 7.0: Build Web Server Solutions with End-To-End Extensibility
>IIS 7.0: Enhance Your Apps with the Integrated ASP.NET Pipeline
>IIS 7.0: Explore The Web Server For Windows Vista And Beyond
>Design and Deploy Secure Web Apps with ASP.NET 2.0 and IIS 6.0
>Fast, Scalable, and Secure Session State Management for Your Web Applications


Tools and Modules

LeechGuard
IconHandler 2.0
DirectoryListing
HttpRedirection
IIS Auth for Wordpress
iisschema.exe
PortCheck.exe v2.0

Popular Posts

- ASP.NET 2.0 Breaking Changes on IIS 7.0
- Develop IIS7 modules and handlers with .NET
- Troubleshoot IIS7 errors like a pro
- Troubleshooting 503 / "service unavailable" errors
- Troubleshooting "server not found" errors
- Create IIS7 sites, applications, and virtual directories
- Run Ruby on Rails with IIS FastCGI
- VS Debugging of ASP.NET applications on Windows Vista
- Stop hot-linking with IIS and ASP.NET

Tags

Search

Go

This Blog

Archives

Good IIS Blogs

Disclaimer

These postings are provided as is with no warranties, and confer no rights. The views expressed in this blog are entirely my own.

Syndication