By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,218 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,218 IT Pros & Developers. It's quick & easy.

"Premature end of script headers: php.cgi"

P: n/a
I have compiled PHP 5.2.3 as a CGI binary, and this works. I can, for example,
do the following:

$ php.cgi hello_world.php
X-Powered-By: PHP/5.2.3
Content-type: text/html

Hello World!

===

However, this completely fails when I attempt to route PHP scripts through this
new CGI executable with .htaccess. My approach is this:

File: doc_root/.htaccess
AddHandler phpFive .php
Action phpFive /php.cgi

(doc_root/php.cgi links to the correct executable)

Any PHP page I visit in my browser now returns a 500 error, and the error log
contains this:

Premature end of script headers: php.cgi

It's clearly not the fault of the PHP executable itself, since it works from the
command line.

===

I have also tried renaming the link so it no longer has a .cgi extension.
Instead, I now get the following errors on all PHP pages.

Warning: Unexpected character in input: ' in php-cgi on line 571
Warning: Unexpected character in input: ' in php-cgi on line 571
Parse error: syntax error, unexpected ',' in php-cgi on line 571

At a wild guess, I'd say that the problem is that the server tries to interpret
the PHP executable rather than execute it as a native binary. Any ideas how I
can stop that?

--
cb
Aug 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Apparently, cgi WILL NOT resolve symbolic links to the binary itself
(though directory links are resolved).

What does this mean?

The symbolic link chain that connects DOC_ROOT/cgi-bin/php.cgi to
/MY_SOFTWARE/php/php-cgi can pass through as many links and directories
as you want, but it may only link to the parent directory that contains
the actual php.cgi file.

It /cannot/ link directly to the executable.

I hope that this helps anyone else who may have had this problem.

--
Christoph Burschka
Aug 1 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.