Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CGI Question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
hybernate20
n00b
n00b


Joined: 22 Mar 2006
Posts: 64

PostPosted: Tue Jun 12, 2007 1:12 pm    Post subject: CGI Question Reply with quote

Maybe this is a stupid question....but I have to know because it is driving me crazy.

I set apache to allow me to execute cgi scripts in my userdirectory. Here is my directive for that:

<Directory /home/nate/public_html>
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>

When I go make a cgi in perl, it only works with the .pl extension. If I try to run

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

with the .cgi extension, I get the "Internal Server Error" with my error in the log saying that my script headers ended prematurely.

So quick recap.....index.cgi doesn't work, but index.pl does, and they are the same file, different extension. WHY?!
Back to top
View user's profile Send private message
nomuus
n00b
n00b


Joined: 10 Apr 2007
Posts: 11

PostPosted: Tue Jun 12, 2007 3:24 pm    Post subject: Reply with quote

http://bontragerconnection.com/library/installation_error_messages.shtml

http://www.google.com/search?q=cgi+script+headers+ended+prematurely&btnG=Search
Back to top
View user's profile Send private message
hybernate20
n00b
n00b


Joined: 22 Mar 2006
Posts: 64

PostPosted: Tue Jun 12, 2007 7:12 pm    Post subject: Reply with quote

Yeah, that link really didn't help me. My perl code is fine, my permissions are fine, I'm not sending any mail, I'm not using any modules. I didn't need the google search link either by the way. I know how to use google...which is why I'm asking here. Google didn't help me.
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2513
Location: Silver City, NM

PostPosted: Tue Jun 12, 2007 7:32 pm    Post subject: Reply with quote

I tried to replicate your problem by modifying 00_mod_userdir.conf: (using Apache-2.2.4-r6)
Quote:
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec +ExecCGI
AddHandler cgi-script .cgi .pl

I could successfully run both printenv.pl and printenv.cgi from my ~/public_html/ directory. I suggest you make sure the permissions and ownership on your two files are identical. If one of the files is a symlink, remove the link and make a copy of the actual file. If that doesn't fix the problem, you might want to go poking around looking for a config option you set that is overriding how .cgi or .pl extensions are treated. The multiple config files makes this a bit more difficult than it used to be but the following commands might help a little:
Code:
$ cd /etc/apache2
$ find -name "*.conf" | xargs grep "cgi"
Back to top
View user's profile Send private message
hybernate20
n00b
n00b


Joined: 22 Mar 2006
Posts: 64

PostPosted: Tue Jun 12, 2007 8:43 pm    Post subject: Reply with quote

Hey thanks! I'll check that out. This is driving me crazy. My permissions are identical, and I don't have any symlinks. I'll just have to check the config files and see if I can find anything wacky.
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2513
Location: Silver City, NM

PostPosted: Tue Jun 12, 2007 8:54 pm    Post subject: Reply with quote

If you get stumped you could save your /etc/apache2 directory to a safe place (like /etc/apache2.save) and re-emerge Apache. It will populate /etc/apache2 with the default config files and it should be very easy for you to get .cgi scripts working. Then copy over your old config piece by piece, restarting apache each time to find out which piece breaks your .cgi script.

Also, have you tried using names other than index.cgi and index.pl? Maybe the problem is associated with how Apache is handling index files.
Back to top
View user's profile Send private message
hybernate20
n00b
n00b


Joined: 22 Mar 2006
Posts: 64

PostPosted: Wed Jun 13, 2007 4:44 pm    Post subject: Reply with quote

Well, I figured it out finally (thanks to the Apache website!). Turns out, I had suexec enabled even though I was 99 percent sure that I wasn't using it. My errors were then due to bad permissions thanks to stupid suexec. I disabled it, and everything seems to be working for me now!
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2513
Location: Silver City, NM

PostPosted: Wed Jun 13, 2007 4:55 pm    Post subject: Reply with quote

Suexec may not be useful if only one person is in charge of a website but when multiple users are writing CGI programs for the same website, it is a godsend.

PS: I'm glad you got your problem fixed.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum