LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Internal server error (Premature end of cgi script) (http://www.linuxquestions.org/questions/linux-server-73/internal-server-error-premature-end-of-cgi-script-749391/)

cbtshare 08-21-2009 05:13 PM

Internal server error (Premature end of cgi script)
 
I'm running centos, apache 2.2 with cgi script .Server has been fine for months, and all of a sudden today I get this error :

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@usershare.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.9 Server at usershare.net Port 80


Nothing changed, unless I was hacked which I doubt.My error logs say,

Fri Aug 21 13:04:35 2009] [error] [client 190.108.166.58] Premature end of script headers: index.cgi

I recompiled apache but nothing!

I'm lost, can any one help me fix this issue plz.

Thank you

acid_kewpie 08-21-2009 05:17 PM

please use useful and informative thread titles and not use words like "urgent" which are usually seen as rude within a voluntary community.

anomie 08-21-2009 05:18 PM

Do you have backups of index.cgi? It sounds like it may have been modified (and broken).

-------
Side note: Please do not use thread titles like "urgent help please". That has nothing to do with your problem.

cbtshare 08-21-2009 05:26 PM

sorry @ mod, didnt mean to come off as "rude"....., anomie I didnt do backups, the script main files don't change I even copied over a fresh index.cgi

anomie 08-21-2009 05:39 PM

Any form of developer/sysadmin change logs or (even better) a HIDS would be very helpful in troubleshooting this problem. Without knowing what someone may have recently changed, it's going to require digging.

Failing all of the above, what does # apachectl -t say at this point?

What other information is available in your access logs and error logs?

cbtshare 08-21-2009 05:45 PM

The command says :-bash: apachectl: command not found

cbtshare 08-21-2009 05:47 PM

as for my logs , thats all thats filled up in there : [error] [client 190.108.166.58] Premature end of script headers: index.cgi, referer:

cbtshare 08-21-2009 05:49 PM

I am the only one that had password to the server, and I am 99% sure no one changed anything

ryan_at_werk 08-21-2009 08:33 PM

post a copy of your index.cgi so we can take a look

cbtshare 08-21-2009 09:42 PM

[code]
#!/usr/local/bin/perl
### ###
use strict;
use CGI::Carp qw(fatalsToBrowser);
use lib '.';
use XFileConfig;
use Session;

$c->{ip_not_allowed}=~s/\./\\./g;
if($c->{ip_not_allowed} && $ENV{REMOTE_ADDR}=~/$c->{ip_not_allowed}/)
{
print"Content-type:text/html\n\n";
print"Your IP was banned by administrator";
exit;
}
my $ses = Session->new();

my $f = $ses->f;
my $db= $ses->db;
my $op = $f->{op};

&CheckAuth() unless $op eq 'login';

if($ENV{HTTP_CGI_AUTHORIZATION} && $ENV{HTTP_CGI_AUTHORIZATION} =~ s/basic\s+//i)
{
&Login(undef,'instant');
print($ses->{cgi_query}->header(-status=>403)),exit unless $ses->{user};
}

cbtshare 08-21-2009 10:04 PM

when I run #perl index.cgi it works.but it wont load in browser

anomie 08-22-2009 06:05 PM

Quote:

Originally Posted by cbtshare
The command says :-bash: apachectl: command not found

Please find the binary and run the command I mentioned as root. If you simply
Code:

su -
it should already be in your PATH.

cbtshare 08-22-2009 10:52 PM

what does the command do really?

I logged in as root via ssh. Doest work.

anomie 08-22-2009 11:42 PM

This is a basic test that you should be aware of going forward. It performs a syntax check on httpd.conf (and any configuration files it includes).

Working example:
Code:

# apachectl -t
Syntax OK

Broken example:
Code:

# apachectl -t
Syntax error on line 6 of /etc/httpd/conf.d/squid.conf:
Invalid command 'ScriptAlias', perhaps misspelled or defined by a module not included in the server configuration

I don't expect it to solve your problem, but I had intended for it to be a quick and easy sanity check...

padlamoij 08-23-2009 12:43 AM

lol.. apachectl not found... ouch.


All times are GMT -5. The time now is 02:11 PM.