lighttpd fails to start!!!???!!!

I logged into a legacy system a few weeks ago, because the web server that was serving an application had ceased performing its function. I quickly noticed that the server program that was running was lighttpd as opposed to apache. Not that I care mind you, but I do tend to have more experience with apache than lighttpd. If you want to skip to the solution, move to “eureka” below.

In any case, I attempted to perform a stop/start on the server to see if that would resolve the issue. The stop succeeded(or so I thought) but the start failed. I ran a quick ‘ps’ to see what was going on and found that the server was still running. Undeterred, I killed the server and ran the start-up script again and it worked. I thought that maybe something must be wrong with the init script. Perhaps this version of lighttpd was installed manually(it happens). I tried running the stop section manually and found that the stop command was unable to locate the pid of the running process. The strange part is that the pid file existed but it did not reflect the pid returned by ‘ps’.

I performed some research(googled it) and found several individuals that had encountered similar issues. Unfortunately, in the true spirit of opensource they just changed the init script to kill -9. This is of course an unacceptable solution unless you like bringing a nuclear weapon to a knife fight so I continued my search looking at the default config files.

Eureka!

server.pid-file            = "/var/run/lighttpd.pid"

Apparently, the process that starts lighttpd performs some magic with the pid that results in this line being needed.