small fixes to add support for php-fpm

A fix for #583 (also opened by me). If you see any problems with it please let me know.