B.3 Debugging Premature End of Script Headers

When you're working with CGI scripts, certain messages can quickly become extremely familiar and tiresome; typically the output in the browser window will be either a blank page or an Internal Server Error page.

This message has several different possible causes. These include, but are not necessarily limited to:

  • The CGI script is either not emitting any output at all, or it is emitting content before the required header lines, or it's neglecting to emit the obligatory blank line between the header and the content.

  • The script encountered an error and emitted the error message instead of its expected output.

  • You're using suexec and one or more of the suexec constraints has been violated.

To test to see if the problem is an error condition or improper CGI response formatting, run the script interactively from the command line to verify that it is emitting content in compliance with the CGI rules.

If you're using suexec, check the suexec logfile to see if there are security constraints being violated.

You can tell if you're using suexec with the following command:

% httpd -l Compiled-in modules:   http_core.c   mod_so.c suexec: disabled; invalid wrapper /var/www/apache/bin/suexec

If you get a message that says that suexec is disabled, you can ignore that as a possible cause of the script's execution problems.

If suexec is enabled, though, you should look at its logfile to get more details about the problem. You can find the logfile with:

# suexec -V  -D DOC_ROOT="/usr/local/apache/htdocs"  -D GID_MIN=100  -D HTTPD_USER="www"  -D LOG_EXEC="/usr/local/apache/logs/suexec.log"  -D SAFE_PATH="/usr/local/bin:/usr/bin:/bin"  -D UID_MIN=100  -D USERDIR_SUFFIX="public_html"

The important line is -D LOG_EXEC="/usr/local/apache/logs/suexec.log"; it tells you exactly where suexec is recording its errors.

You can find out more about CGI and suexec here:

  • The CGI specification, http://CGI-Spec.Golux.Com/

  • Recipe 8.12

  • The suexec manpage

Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net