View previous topic :: View next topic |
Author |
Message |
hybernate20 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 22 Mar 2006 Posts: 64
|
Posted: Tue Jun 12, 2007 1:12 pm Post subject: CGI Question |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
nomuus n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1260646657461c019f51242.gif)
Joined: 10 Apr 2007 Posts: 11
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
hybernate20 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 22 Mar 2006 Posts: 64
|
Posted: Tue Jun 12, 2007 7:12 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
BitJam Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 12 Aug 2003 Posts: 2513 Location: Silver City, NM
|
Posted: Tue Jun 12, 2007 7:32 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
hybernate20 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 22 Mar 2006 Posts: 64
|
Posted: Tue Jun 12, 2007 8:43 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
BitJam Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 12 Aug 2003 Posts: 2513 Location: Silver City, NM
|
Posted: Tue Jun 12, 2007 8:54 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
hybernate20 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 22 Mar 2006 Posts: 64
|
Posted: Wed Jun 13, 2007 4:44 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
BitJam Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 12 Aug 2003 Posts: 2513 Location: Silver City, NM
|
Posted: Wed Jun 13, 2007 4:55 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|