PHP Fastcgi on IIS

In recent weeks I’ve been doing alot of work with PHP and IIS, whilst not my favoured web server I have been pleasantly impressed with the results.

In performance benchmarks, running PHP under IIS is up to 766% (yes 766%) quicker running as FastCGI versus ISAPI. With modest amounts of caching we’ve succesfully managed to handle over 6,000,000 page requests a week on just one box.

There is a nice article here outlining the benchmark figure quoted above, along with the installation method required. I had initially thought about rewriting the article, but really it covers everything in sufficient detail - why try and reinvent the wheel.

There were however a couple of points, which left me scratching my head for a while, and hopefully this will come in useful for someone else.

  1. Be sure to enable fastcgi_impersonate within you’re PHP.ini
  2. When restarting the IIS, be sure to kill off all the php.exe listed within the task manager. A batch file, can come in very useful to kill these off.
  3. DLL hell. I’ve found that if you are connecting to a SQL Server, the isapi_fcgi.dll can be very finicky about which SQL Server library it uses, in comparision the php5isapi.dll will use pretty much anything. Go figure.

All in all, I’m very happy with the results of using the FastCGI API for PHP, however I would only advise using it where demand required i.e. within high traffic environments. The PHP ISAPI component can be installed straight from the installer and to is more stable. The PHP FastCGI component on the other hand takes a little bit of tweaking, and can give some strange responses at time.


About this entry