I was having an issue with random 502 gateway errors using nginx and php-fpm. In my case I discovered a scenario where various php.ini error_log settings and error_reporting lev
I've run into this on windows machines running iis and php in fastCGI mode so it isn't just a nix problem.
The culprit was php logging as well. You don't have to set it to a static directory though if you grant proper permissions it can write to the same directory that the script resides in. (Can be very helpful if you have a large and complicated site)
My server is setup this way and I just added a rule to not serve the error logs to the public.
To sum it up, CHECK PERMISSIONS! =)