"Premature end of script headers: php.cgi"


#1

I’ve installed PHP 5.2.3, linked doc_root/php.cgi to the proper executable and entered this in doc_root/.htaccess:

AddHandler phpFive .php Action phpFive /php.cgiThe result is that all pages return a 500 error and leave the following message in error.log:

What’s wrong?


#2

Accidental solution:

removed symbolic link to php.cgi, instead COPIED php.cgi file.

Diagnosis:

CGI does not resolve symbolic links. If the Action you define in .htaccess points to a symbolic link that resolves to php.cgi, CGI will try to execute the link.

Solution:

However, directories can be linked. So instead of making a link from cgi-bin/php.cgi to ~/software/php/cgi-bin/php.cgi, make a link from cgi-bin to ~/software/php/cgi-in. The linking chain will work as long as the final destination is a directory containing the real file.