The short answer: you may need to switch to a version of PHP that uses FastCGI.
Log into your Cpanel (control panel.) Under the “Software/Services” sections, click on “PHP Config”. If you don’t have one of the PHP options with “(FastCGI)” selected, chose one — the latest version with FastCGI would be a good place to start — and hit the “Save” button at bottom. Then try running your PHP script again.
I hope this helps. I could have used knowing this about 3 hours of troubleshooting ago.
It may work for other web hosts who use Cpanel also.