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
If above steps don't help you solve your issue, check if you have eaccelerator enabled.
Disable it globally by disabling the load .so entry in either your php.ini or php.d/eaccelerator.ini
All problems are gone. Seems like the accellerator fails in certain situations in combination with php-fpm.