Lighttpd, spawn-php and daemontools

This has been sitting forgotten on the draft queue for a while. I’m not using this setup at the moment, but the information is still useful.

Over the weekend I spent some time weekend figuring out how to get Knowledge Tree on lighttpd with spawn-php and lighttpd. Quite apart from the memory saving with using lighttpd, with spawn-php and fcgi its much easier to build a sane suExec style config.

According to this ktDMS forum item to run ktdms under lighttpd you need to set cgi.fix_pathinfo=1 in php.ini. According to the lighttpd fastcgi docs this also should run with “broken-scriptfilename” => “enable” option in lighttpd.conf.

With the included script spawn-php from lighttpd, apart from setting the user/group and socket settings appropiately, I also added ‘-n’ (no fork) to EX.


if test x$UID = x0; then
-  EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN"
+  EX="$SPAWNFCGI -n -s $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN"
else
-  EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN"
+  EX="$SPAWNFCGI -n -s $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN"
fi

#! /bin/sh
# spawn-php/run

exec 2>&1
exec ./spawn-php
#! /bin/sh
# spawn-php/log/run

umask 0027
exec setuidgid samba multilog ./main

Comments are closed.