Yes I know there are numerous articles and forums out there which talk about this.

Why am I writing about this again?

That's because there is still some doubt out there on how to get PHP to work with Lighty.

In this blog post I would be providing the configuration files as well for Lighty and PHP whcih is missing in all the forms and general discussions out there. This would help folks get started faster.

You can download the files here:- PHP.ini, lighttpd-inc.conf

The PHP version I am using is 5.2.6 and the Lighty version is 1.4.19-1 which I downloaded from WLMP project. The good thing is they have already complied LightTPD to work with windows.

The link to download LightTPD is

The idea is to start PHP in fastCGI mode. That way you are opening a port that PHP listens to and whenever Lighty gets a PHP request it just forwards the same to be executed as a PHP script.

The important part of the Lighty configuration file is mod_fastcgi which exists in server.modules. Remove the hash(#) before mod_fastcgi in the config file.

The next important part is:-

fastcgi.server = ( ".php" =>

                              ( "localhost" =>
                                  "host" => "",

"port" => 1879, "docroot" => "c:/LightTPD/htdocs/"


What's happening here is that I am asking Lighty to forward all php requests on to port 1879 on the host ip which is a localhost ip. Also what's important is you mention the docroot location of where the php files would be located. (This part is important.)

Lets talk about the php.ini file for now.

Here are the important parts of the file:-

Force Redirect should be set to enabled for security reasons.

cgi.force_redirect = 1

Fix Path info should also be turned on as is spoken of in the Lighty documentation


Once you have setup your configuration files what you need to do is make sure you do not have any other webservers running on port 81. The reason I use port 81 is because of IIS. IIS is very greedy when it comes to port 80 and does not allow one to change the listening port.

An easy way to find out if any severs are listening on port 81 is to run the command netstat -a and look for any entries for port 81. I am assuming that you have not yet started Lighty.

Once we have confirmed that nothing is listening on port 81 we can fire up Lighty and type in http://localhost:81. If you get a page telling you about Lighty and stuff you have completed the first hurdle of getting a basic http server running with the new configuration file.

Once again assuming you have completed the previous step type php-cgi.exe -b through the command line. Of course before running this command I am assuming that you have changed he path to the location where the php home directory resides. Also make sure that you have php-cgi.exe in the home directory. If you do not have it don't fret. Just download the zip version of the PHP installation and extract php-cgi to the folder.

Once you are done create a file having the function phpinfo() in a file ending with .php in the htdocs folder.

If everything has gone well you should see all the details of your php server on typing the name of the php file after the localhost url.

Hope this helps.