Recently, I’ve been having issues with php-cgi.exe crashing on Apache 2.2 and IIS7 on Windows 2008. So, I’ve been searching for alternative ways of running my PHP application.

I came across nginx and lighttpd.

Let’s try LightTPD 1.4.28 and PHP 5.3.5.

Get the Windows binaries for LightTPD from WLMP project: http://en.wlmp-project.net/downloads.php. I chose the ZIP package with SSL support.

Get the Windows binaries for PHP from: http://windows.php.net/download/. I chose the ZIP package VC9 x86 Non-Thread-Safe.

Uncompress them into drive C: so that we can have C:\LightTPD and C:\PHP .

Go to C:\LightTPD\conf\
Edit lighttpd-srv.conf. Change file relative paths to absolute paths to read:

server.errorlog      = "c:/lighttpd/logs/lighttpd-srv.error.log"
accesslog.filename   = "c:/lighttpd/logs/lighttpd-srv.access.log"
server.pid-file       = "c:/lighttpd/logs/lighttpd-srv.pid"
include "c:/lighttpd/conf/lighttpd-tag.conf"
include "c:/lighttpd/conf/lighttpd-inc.conf"

Edit lighttpd-inc.conf.
Enable mod_fastcgi among server.modules and check following settings:

server.document-root = "C:/LightTPD/htdocs/"
server.upload-dirs = "C:/LightTPD/tmp/"
fastcgi.server = ( ".php" =>
    ("localhost" => ("host" => "127.0.0.1", "port" => 521 ) )
)

Go to C:\LightTPD\htdocs
Create phpinfo.php with content:


Go to C:\PHP.
Have a copy of php.ini-production as php.ini.

Run PHP CGI:

C:\PHP>php-cgi.exe -b 127.0.0.1:521

Run LightTPD:

C:\LightTPD>LightTPD.exe -f conf\lighttpd-srv.conf -m lib

Go to:
http://localhost/phpinfo.php

Voila!

It is definitely worth trying. Consider modifying the config files so that LightTPD can quickly serve static files such as HTML, CSS, JavaScript, JPEG, PNG files; and PHP files are passed to the CGI application or service for further processing. Also consider the process recycling settings, which is mainly affected by setting the number of requests served before the process is killed.

References:
http://php.net/
http://www.lighttpd.net/
http://redmine.lighttpd.net/wiki/1/TutorialLighttpdAndPHP