LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-01-2003, 11:40 PM   #1
Chiabert
LQ Newbie
 
Registered: Oct 2003
Distribution: Redhat Linux 9
Posts: 6

Rep: Reputation: 0
Linux 9 installed :: Apache CGI Scripts


Hi, trying to install Redhat Bugzilla into Linux 9. Can anyone see an error in these two sets of codes to generate the following output on Apache?

Apache Output:
Server error!

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

Error message:
Premature end of script headers: index.cgi

If you think this is a server error, please contact the webmaster

Error 500

localhost
Wed Oct 1 20:45:44 2003
Apache/2.0.40 (Red Hat Linux)



Here is my index.cgi:

#!/usr/bonsaitools/bin/perl

# -*- Mode: perl; indent-tabs-mode: nil -*-

# More commented stuff...

# Suppress silly "used only once" warnings
use vars qw{ %COOKIE };


###############################################################################
# Script Initialization
###############################################################################

# Make it harder for us to do dangerous things in Perl.
use strict;

# Include the Bugzilla CGI and general utility library.
use lib ".";
require "CGI.pl";

use vars qw(
$template
$vars
);

# Establish a connection to the database backend.
ConnectToDatabase();

# Check whether or not the user is logged in and, if so, set the $::userid
quietly_check_login();

###############################################################################
# Main Body Execution
###############################################################################

$vars->{'username'} = $::COOKIE{'Bugzilla_login'} || '';

# Return the appropriate HTTP response headers.
print "Content-Type: text/html; charset=utf-8\n\n";

# Generate and return the UI (HTML page) from the appropriate template.
$template->process("index.html.tmpl", $vars)
|| ThrowTemplateError($template->error());


The header looks correct to me. I have no idea what might be generating this error from Apache. If anyone has any suggestions, please let me know!
 
Old 10-01-2003, 11:44 PM   #2
Chiabert
LQ Newbie
 
Registered: Oct 2003
Distribution: Redhat Linux 9
Posts: 6

Original Poster
Rep: Reputation: 0
It might be this, am I handing CGI's correctly in apache with this statement?

#########################################################################
AddHandler cgi-script .cgi .pl
<Directory "/var/www/html/bugzilla-public">
Options +ExecCGI
AllowOverride None
</Directory>
 
Old 10-24-2003, 05:45 AM   #3
jbond007
LQ Newbie
 
Registered: Oct 2003
Posts: 1

Rep: Reputation: 0
Help

Sorry to trouble you. Did you get this resolved?
Im having the same trouble.
Driving me nuts.
Thanks
 
Old 01-06-2004, 10:20 AM   #4
sibil
LQ Newbie
 
Registered: Jan 2004
Posts: 2

Rep: Reputation: 0
Were y'all able figure out the issue... I am in need of serious help. We used to use linux 7.1 and our java script worked fine. Due to an electircal issue we had to rebuild the server. We loaded linux 9 and now our java script does not run and gives the error premature end of script header. I don't know enough about linux or apache to know what may have changed between these versions. Any help would be appreciated.

Thanks,
 
Old 02-26-2004, 02:01 PM   #5
clinton
Member
 
Registered: Oct 2003
Location: Vancouver
Distribution: RH Enterprise AS 3
Posts: 47

Rep: Reputation: 15
P

Sibil,

Are you using Java or Javascript? (They are different).

It sounds like you're using Java, and Java requires a specific, secondary web-server (not sure if it's a webserver or not) call Tomcat.

Tomcat is also produced by the Apache folks.

check out

http://jakarta.apache.org/tomcat/

for more info on it.

Back to the main thread, I am running into the same problem with
"Premature end of script headers"

With a very simple script:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";


everything works fine.

However, for a script that I wrote on another server a year ago and worked without problems I get the error above.

I have changed the shebang line (#!/usr/bin/perl) to point to the correct location of perl.

my httpd.conf is set at default (for CGI stuff and reads):


ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<IfModule mod_cgid.c>

Scriptsock run/httpd.cgid
</IfModule>

<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Permissions are set correctly to everything, and the error log files do not contain anything other than the error above.

I would like to eventually give personal cgi-directories, but the methods I've used to specify them results in the same error.

I had another question also: What happens to .html files put into cgi-bin directories? Are they read as .html or does apache try to execute them?

Last edited by clinton; 02-26-2004 at 02:13 PM.
 
Old 05-16-2004, 12:35 PM   #6
sreekumar69
LQ Newbie
 
Registered: May 2004
Posts: 2

Rep: Reputation: 0
Angry

I am absolutely a newcomer to the linux environment.
I have been trying to configure bugzilla with the same result:

Premature end of script headers: index.cgi
Do anybody have a solution?
 
Old 05-17-2004, 01:32 PM   #7
clinton
Member
 
Registered: Oct 2003
Location: Vancouver
Distribution: RH Enterprise AS 3
Posts: 47

Rep: Reputation: 15
If you have root access look for /sbin/suexec

Move the file to another location and restart your web server. I found this program to be something of a problem, and since I have moved it things have been working OK. I'm not sure WHY it's causing a problem though.

Furthermore, I don't think you are permitted to write to CGI directories anymore. apache.org does not state this (at least, I haven't found it). I have not attempted this with any recent script, so I cannot say if this is the case or not, but it is easily tested. You _are_ permitted to write to a non-CGI directory though, such as /tmp/

I used to have web-references for all this, but I can't find them anymore.
 
Old 05-17-2004, 02:20 PM   #8
sreekumar69
LQ Newbie
 
Registered: May 2004
Posts: 2

Rep: Reputation: 0
Wink

Hi friends,

I checked the index.cgi. Earlier the first line read:
#!/usr/bonsaitools/bin/perl -wT

I changed it to

#!/usr/bin/perl -wT ( I could not find any directory named 'bonsaitools' in the /usr directory.

And it works !!

However, I cannot follow any link since the other .cgi files should have the same problem. Editing all the related .cgi files would be a daunting task.

Any solution to this?
 
Old 07-29-2004, 11:43 AM   #9
sparker32
LQ Newbie
 
Registered: Jul 2004
Posts: 2

Rep: Reputation: 0
Even though my symbolic link looks correct I am having hte same problem/error messages in my logs and screen.

I mad a symbolic link so the cgi apps would find perl, however it doesn't seem to be working.

mkdir -p /usr/bonsaitools/bin
cd /usr/bonsaitools/bin
ln -s /usr/bin/perl perl
 
Old 07-29-2004, 03:37 PM   #10
linuxlastslonge
Member
 
Registered: Jun 2002
Location: Franklin, IN
Distribution: Debian, CentOS, Mac OS X
Posts: 158

Rep: Reputation: 30
Exclamation check syntax of configuration files

chiabert :

Quote:
AddHandler cgi-script .cgi .pl
<Directory "/var/www/html/bugzilla-public">
Options +ExecCGI
AllowOverride None
</Directory>
there should not be a plus next to ExecCGI . also, run a config test after saving httpd.conf to make sure there are no type-o's.
plus.... make sure your cgi is executable!!!!!!

Code:
chmod +x cgiscript.cgi
you should be able to execute the CGI script from the shell and it return HTML'ized output.



hope this helps!!!!
 
Old 07-29-2004, 04:05 PM   #11
sparker32
LQ Newbie
 
Registered: Jul 2004
Posts: 2

Rep: Reputation: 0
FYI

My symbolic link was not pointing to the perl file (actually it was pointing to a directory called perl) ... hence that was my problem.

These commands are correc though:
mkdir -p /usr/bonsaitools/bin
cd /usr/bonsaitools/bin
ln -s /usr/bin/perl perl

Maybe this helps someone else down the road.
 
Old 07-29-2004, 10:17 PM   #12
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
A sed job can take care of that for you, eg
Code:
sed -i s/'^\#\!.*'/'\#\!\/usr\/bin\/perl'/ *.pl
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache & cgi scripts maze_fire Linux - Networking 1 08-12-2004 03:58 PM
help setting up Apache to use cgi scripts limiter Linux - Software 2 03-25-2004 02:59 PM
configuring apache for cgi scripts ash_r_c Linux - Software 1 09-23-2003 05:03 PM
Apache 2.0.43 will not run cgi scripts RobbieRoy Linux - Networking 5 09-04-2003 03:56 PM
Apache cgi scripts! boyinfrance Linux - Newbie 2 06-22-2002 11:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration