Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache 2.0.4 cgi configuration

Status
Not open for further replies.

wasntme0418

Programmer
Aug 7, 2003
1
US
I am a newbe to linux and apache, but have a good understanding. I am taking over a server where cgi is not working, I get premature end of headers in error_log. Its redhat 7, apache 2.0.40. I have tried many configurations of the httpd.conf (with restart) no avail. I have rechecked permissions + ownership, nothing. here is a snipit of httpd.conf.

<IfModule prefork.c>
LoadModule cgi_module modules/mod_cgi.so
</IfModule>

<IfModule worker.c>
LoadModule cgid_module modules/mod_cgid.so
</IfModule>

User apache
Group apache
UseCanonicalName Off
DocumentRoot "/var/<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "/var/
Options Indexes FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html index.html.var index.htm
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>

TypesConfig /etc/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>
# MIMEMagicFile /usr/share/magic.mime
MIMEMagicFile conf/magic
</IfModule>
ScriptAlias /cgi-bin/ "/var/
<IfModule mod_cgid.c>
Scriptsock run/httpd.cgid
</IfModule>

<Directory "/var/ AllowOverride None
Options +ExecCGI
Order allow,deny
AddHandler cgi-script .cgi .py .pl
Allow from all
</Directory>
AddHandler cgi-script .cgi


I am calling a very simple hello.cgi script that is in cgi-bin. The script runs fine on command line. I have also tried htaccess file, nothing. I don't think I understand part of the configuration, or just missing something. Thanks for any help.
 
Either use:

PerlSendHeader On

to get Apache to send headers for you (the simplest method) or make sure that you send the httpd headers from your program yourself. The minimum required is generally something akin to:

Content-type: text/html

followed by a blank line, as the very first thing your program produces - running it on the command line will show whether or not you're doing it correctly. You could either manually print this:

print "Content-type: text/html\n\n";

or if you have the CGI module installed you could use:

print CGI->header;

You might want to cast a quick look at and its derivative links.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top