I had similar issues, and it turned out the memory limit settings (memory_limit) in my php.ini were too low. With FastCGI, in order to get some PHP errors, you have to set logging to a file instead of displaying them. When you display the PHP errors, this code just ends up confusing FastCGI, which then results in an Apache server error (500).
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.