Apache CGI error.
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/
# Additional to mod_cgid.c settings, mod_cgid has Scriptsock <path>
# for setting UNIX socket for communicating with cgid.
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
Allow from all
# 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
And I put "test.cgi" file in my /home/david/publlic_html/cgi-bin directory:
print "Content-type: text/html\r\n\r\n";
print "Hello, World.";
Here is the error message I got:
The server encountered an internal error and was unable to complete your request.
Premature end of script headers: blah.cgi
If you think this is a server error, please contact the webmaster
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.
$cgi = new CGI();
print "hello world";
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:
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:
what happens if you put
without the "+"
just trying out all possible avenues here...dont know if it might make
a difference but its worth a try....
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.