PHP FastCGI on LightTPD

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: I chose the ZIP package with SSL support.

Get the Windows binaries for PHP from: 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"       = "c:/lighttpd/logs/"
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" => "", "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.


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

Run LightTPD:

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

Go to:


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.


Leave a Reply