-
Apache CGI error.
Hi,
I'm using Apache/2.0.40 on Redhat 9. I'm trying to figure out how to permit CGI script outside of ScriptAlias directories. I added following code to my httpd.conf file:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<IfModule mod_cgid.c>
#
# Additional to mod_cgid.c settings, mod_cgid has Scriptsock <path>
# for setting UNIX socket for communicating with cgid.
#
Scriptsock run/httpd.cgid
</IfModule>
...
#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
...
#
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
AddType application/x-tar .tgz
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler cgi-script .cgi .pl
<Directory "/home/*/public_html/cgi-bin">
Options +ExecCGI
</Directory>
And I put "test.cgi" file in my /home/david/publlic_html/cgi-bin directory:
#!/usr/bin/perl
print "Content-type: text/html\r\n\r\n";
print "Hello, World.";
Here is the error message I got:
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: blah.cgi
If you think this is a server error, please contact the webmaster
Error 500
...
I checked the permissons and everything I could but still couldn't figure out why. Can anyone help me?
-
Try usiing the following code and see what happens.
Code:
#!/usr/bin/perl -w
use CGI;
$cgi = new CGI();
print $cgi->header(),"\n";
print $cgi->start_html(),"\n";
print "hello world";
print $cgi->end_html(),"\n";
-
sykkn,
I got the same error message. The strange thing is even if I don't put anything
in test.cgi except for #!/usr/bin/perl -w, I still get the same result.
-
have you uncommented out the following line
AddHandler cgi-script .cgi
if not then uncomment it out and restart the webserver and give it a shot.
-
OK, sorry that didn't help just wanted to make sure that code I knew worked still didn't work for you.
I have found people saying they got that error due to permissions. Specifically write/execute permissions for users other than yourself. What are your current permissions? Try chmod'ing to 711 and see if that works for you.
I'll keep researching until I hear back.
-
if you run it from the command line, does it work correctly?
try uncommenting the line if its commented:
AddHandler cgi-script .cgi
Also you might want to check out this link:
http://perlmonks.thepen.com/24447.html
-
Yes, I did uncomment the "AddHandler cgi-script .cgi" line. And I set my permission to 755. I ran the script on command line and everything looks fine. Plus, I put the script in /var/www/cgi-bin/ directory and it ran fine there as well. The "Server error!" message is still there. I'm lost :cry:
-
hmmm....
what happens if you put
Options ExecCGI
instead of
Options +ExecCGI
without the "+"
just trying out all possible avenues here...dont know if it might make
a difference but its worth a try....
-
nikhil,
I tried it and it's still not working. :(
-
I read that you need different permisions to use the scripts is your public_html directory. Trying chmod'ing to 711 and running it and then try 770 and running it.