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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RH 7.1 apache cgi-scripts

Status
Not open for further replies.

optimised

Technical User
Jun 21, 2001
96
US
I am trying to get my web server to execute cgi-scripts. I'm starting off using this small script listed below. I put the script in the /var/ directory.

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

I have done a 'chmod +x /var/ to test it

I ran >perl -c test.cgi
syntax fine
Then >perl - w test.cgi
Hello World

Command line >perl myscript.cgi works fine

But running I keep getting internal error 505

Would there be something missing or mis-configured in my httpd conf file.

These are a few sections from my httpd.conf
//

ScriptAlias /cgi-bin/ "/var/
<Directory &quot;/var/AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

AddHandler cgi-script .cgi

# Virtual host mydomain.com
<VirtualHost x.x.x.x>
DocumentRoot /home/mydomain/www/
ServerName ServerSignature email
</VirtualHost>
 
I had the same problem for weeks and tried every configuration under the sun and never found the right one. I just started adding the line &quot; use CGI; &quot; in the next line after your path to perl at the top of your script. All my scripts seem to work fine. Good luck
 
Hi RhythmAce,

I have been trying so many different changes for about a week now with no success.

Do you mean like this--Perl is new to me as well

#!/usr/bin/perl
&quot;use CGI;&quot;
print &quot;Content-type: text/html\n\n&quot;;
print &quot;Hello World\n&quot;;

 
Hi,

Regarding the above - 'use CGI' refers to CGI.pm and it's true that many CGI scripts use code in the CGI module so if you don't have it installed you'd want to grab it from cpan --> and install. The author's documentation is here --> .

However, I don't think this has any bearing on your error because the 'hello world' script uses 'pure' perl and calls nothing from the CGI.pm library. Have you got the mod_cgi module in your httpd.conf ?

LoadModule cgi_module modules/mod_cgi.so

Rgds
 
I'll have to check on the LoadModule
Seems that if it would run from command line it would run in browser. I must have something misconfigured. Path or something.

Thanks


#!/usr/bin/perl
#
print &quot;Content-type: text/html\n\n&quot;;
print &quot;Hello World\n&quot;;

I ran >perl -c test.cgi
syntax fine
Then >perl - w test.cgi
Hello World

command line works fine returns- Hello World.
/cgi-bin>#perl test.cgi

But running I keep getting internal error 505
Error_log
[error] (2) No such file or directory: exec of /home/mydomain/[error] Premature end of script headers

## httpd.conf - configuration for the Apache web server
#enable cgi-scripts
AddHandler cgi-script .cgi .pl

ScriptAlias /cgi-bin/ &quot;/home/mydomain/
<Directory &quot;/home/mydomain/Options None
AllowOverride None
Order allow,deny
Allow from from all
</Directory>

# Virtual host mydomain
<VirtualHost x.x.x.x>
DocumentRoot /home/mydomain/www/
ServerName ScriptAlias /cgi-bin/ &quot;/home/mydomain/ServerSignature email
</VirtualHost>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top