A simple reqest: I wanted to run a cgi script from my public_html dir in my home dir. So I set the appropriate permissions and the ExecCGI option in my Apache2 config and tried the script. It failed. The error log reported “Premature end of script headers”, so there was obviously something wrong with the script.
But no! The script worked when I tested it. It just wouldn’t work when Apache2 tried it.
I had no idea what was happening, so I tried some other scripts. A pattern soon emerged: any script in my home dir would fail. After spending so long getting this far, I’m glad that my first guess at the real problem was correct.
It appears that Apache2 won’t execute scripts in userdirs if it suspects that someone other than the user may be able to affect them, so it didn’t like my scripts because my directories had group write permission. A quick
chmod g-w ~/public_html
was enough to make it all work.