Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
[Fri Jan 29 20:23:28 2010] [error] [client] Premature end of script headers: header.php
[Sat Jan 30 10:22:42 2010] [error] [client] (8)Exec format error: exec of '/var/www/cgi-bin/header.php' failed

how to fix this ? basically a .cgi script loads header.php which contains javascripts and some php stuff.....

i notice .cgi script runs fine but none of the javascripts and php things work.

share|improve this question
You've given us so little to go on that most of us will be making a complete shot in the dark answering this. Anything else you feel like you can tell us? Are you wanted someone to explain the error message or fix some script. You may want to try stackoverflow. – Patrick R Jan 30 '10 at 23:08

The best anybody can do without more information, since you've given almost none, is guess. Here's mine:

You've either got a missing semicolon or parenthesis or curly brace somewhere (or some other delimiter or bracketing character) or there are DOS line endings (\r\n) where there should be Unix ones (\n).

share|improve this answer

Long shot, but try adding

AddHandler application/x-httpd-php .php

to your apache configuration file.

share|improve this answer

Try to see if your web server has something like this i.e in Apache:

ScriptAlias /cgi-bin/
<Directory /cgi-bin/>
   Options ExecCGI ...

The forces the entire directory to be executable ( like you're trying to run a python/perl script )

If you have that - make sure your file is executable ( chmod +x ... )

And check for the php interperter ( maybe ) at the first line of the CGI script like:

share|improve this answer

i've two ideas:

  • perhaps you have a permission problem with your php file. make sure it has the right permissions for owner and group.
  • perhaps you are mixing html header and body elements. be sure you are including the php file at the right position.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.