In the logs I see this:

[Fri Nov 21 09:02:15 2008] [error] [client 76.17.99.50] Premature end +of script headers: test_ult.cgi
My test script looks like this:

#!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); $| = 1; my $q = CGI->new(); print $q->header, $q->start_html('test.cgi at ult****.com'), $q->h1("Found me in ult****.com vhost "), $q->end_html; $| = 0; 1;
The Q&A section (How to get over 'premature end of script headers' in Apache?) on this site mentions that suExec could be an issue and in this situation the relevant CentOS / plesk server has an http.conf file enabling suExec.

Carp responds with a blank browser screen (and empty source).

As root, running this from a command line, look like this:

cgi-bin]# ./test_ult.cgi Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>test.cgi at ult****.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <h1>Found me in ult****.com vhost </h1> </body> </html> cgi-bin]#
So I have a couple of questions here. Is there a simple way, as root, from the command line, to run this script as the apache user? If this script is not running as apache, how would I determine what user suExec has it running as? Can anyone offer any other pointers to help me determine what my issue here might be?

My real script (nms' FormMail.pl) is also throwing this same error. I usually work in Debian, not CentOS. I usually work at a cli, and am not use to seeing Plesk written config files warning me I will break everything should I edit them. Not sure to what extent this unusual environment may be a factor. I'm hopeful that if I can figure this out for a simple test script, I'll be able to translate this to the real issue I face this morning.

-- Hugh

UPDATE:

grep apache /etc/passwd says: apache:x:48:48:Apache:/var/www:/sbin/nologin
ANOTHER UPDATE:

Thanks all. And thank you ig and eye for the pointers about suExec and SELinux. And I had not known how to set a temporary shell with the su command. That looks useful for the future.

To resolve this issue Friday night, I had to immerse myself in the suExec documentation for the first time and feel that I have finally wrapped my head around how that works. Once doing so, it was a rather quick path to resolving this issue. But first I had to spend an hour or two immersing myself in literature about seLinux, before finally assuming that it was not the issue in this case. However there is more practical advice in eye's and ig's posts below, than in the articles I read Friday. Fully understanding seLinux will have to wait for another day, but it will start with a review of this thread, when the time comes. Thanks again.

if( $lal && $lol ) { $life++; }

In reply to Premature end of script headers more annoying than usual . . . by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.