LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-24-2003, 04:39 PM   #1
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Rep: Reputation: 15
cgi with apache


I am now trying to get cgi to work with Apache 1.3 (on RHL 7.3) and here is what I have done so far:

ScriptAlias /cgi-bin/ "/home/httpd/domain/cgi-bin"

<Directory "/home/httpd/domain/cgi-bin">
AllowOverride None
Options None
Order allow, deny
Allow from All
</Directory>

AddHandeler cgi-script .cgi .pl

And I have also done chmod to the folders and I set all of the permissions.

The error message that I get when I go to www.domain.com/cgi-bin is:

Forbidden
You don't have permission to access /cgi-bin/ on this server.

I have set up the folder so that anybody can access it though.

And if I go to www.domain.com/cgi-bin/script.pl I get a 404 error.

What am I doing wrong?

Thanks
 
Old 02-24-2003, 04:44 PM   #2
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
What exactly did you set the permissions to? cgi-bin should have permissions of 755.
 
Old 02-24-2003, 05:11 PM   #3
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
I had the permission to 755, and just to make sure I did:

chmod 755 cgi-bin

again and I still get the forbidden message. Do I have to have a specific user and group? Right now for Apache, I have nobody for the user and group and I have that also for the cgi-bin folder.

Thanks
 
Old 02-24-2003, 06:37 PM   #4
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
If this helps, I logged on as root on my Apache server and went to:

http://localhost.localdomain/cgi-bin

and I also get the Forbidden error.
 
Old 02-24-2003, 07:49 PM   #5
English Guy
LQ Newbie
 
Registered: Feb 2003
Posts: 6

Rep: Reputation: 0
AddHandler is spelt wrong? This maybe stopping the execution of .cgi & .pl.
Also, as you don't have a slash after cgi-bin, this may prevent you from viewing files in the directory using a browser.

Worth a try at least....
 
Old 02-24-2003, 07:56 PM   #6
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
AddHandler wasnt spelt wrong, I just copied it over wrong. I tried the slash thing, and it still didnt work. I made a folder called cgi and I changed the ScriptAlias and the Document to point to that folder and I also got the forbidden error.
 
Old 02-24-2003, 08:12 PM   #7
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
Also, even if I dont put anything in the cgi-bin folder, I still get the forbidden message, not an "index of" page.
 
Old 02-24-2003, 10:07 PM   #8
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
I think that I am getting somewhere. Now if I go to domain.com/cgi-bin I get a 404 error, not what I expected, but its an improvement. I moved

<Directory/home/httpd/domain/cgi-bin>

outside of the

<IfModule mod_alias.c>

I have files in the folder, but I am getting a 404 error. How can I correct this now? If I go to www.domain.com/cgi-bin/script.pl I also get a 404 error.

Thanks
 
Old 02-25-2003, 09:01 AM   #9
robert j.
LQ Newbie
 
Registered: Feb 2003
Location: holland
Posts: 1

Rep: Reputation: 0
I am new to this as well, but i looked in my commonhttpd config and it looks like this
<Directory /home/*/public_html/cgi-bin>
Options +ExecCGI -Includes -Indexes
SetHandler cgi-script
</Directory>

I am not sure, but i think here the execution of cgi files is permitted, and i missed the cgi-option in the first post. May be helpful.

I am wrestling with a slightly different problem, i can execute cgi scripts, but not from a form which has form action method is post. when i send the form it returns a forbidden error. in my browsers address the script is adressed, and when i press the reload button, the script gets executed. So in my case the action post somehow is not permitted, but have not yet found out why. geuss it has something to do with the action directive.
 
Old 02-25-2003, 09:24 AM   #10
rewt
Member
 
Registered: May 2001
Posts: 44

Rep: Reputation: 15
Dont forget to restart apache when you make changes...

Mine looks like this:

drwxr-xr-x root root cgi-bin

LoadModule cgi_module /usr/lib/apache/1.3/mod_cgi.so

AddHandler cgi-script .cgi .pl

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

Now I dont allow directory listings so I have to call a script directly or I get the same error. Here is a little script that works if named script.cgi and chmod 755 and placed in your cgi-bin and called http://www.domain.com/cgi-bin/script.cgi will list all your environment variables. I use this to check and see if costomer cgi-bin is working correctly or not.

<code>

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html><head><title>Simple CGI Program!!!</title></head><body>\n";
for (keys %ENV) {
print "$_ = $ENV{$_}<br>\n";
}
print "</body><</html>\n";

</code>


Hope this helps,
rewt
 
Old 02-25-2003, 04:06 PM   #11
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks for the suggestions, I am still having a problem. I am now getting a Forbidden error again. Here is what I have for my httpd.conf file so far that deals with CGI:

<IfModule mod_alias.c>

ScriptAlias /cgi-bin/ "/home/httpd/domain/cgi-bin/"

<Directory "/home/httpd/domain/cgi-bin/">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

</IfModule>

AddHandler cgi-script .cgi .pl

And for the file permissions, I have:

drwxr-xr-x 2 nobody nobody 4096 Feb 24 16:17 cgi-bin

I tried changing the directory, but I got the same Forbidden error.

Thanks for your help.
 
Old 02-25-2003, 06:09 PM   #12
English Guy
LQ Newbie
 
Registered: Feb 2003
Posts: 6

Rep: Reputation: 0
Try this. REM out the ScriptAlias & include Options +ExecCGI. This will cause any script to be able to be executed in any directory. If this doesn't work, this is a permissions issue.

Code:
<IfModule mod_alias.c>
 
    ##ScriptAlias /cgi-bin/ "/var/www/html/" 
    #
    # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #

    <Directory "/var/www/html/"> 
        AllowOverride Options
        Options +ExecCGI
        Order allow,deny
        Allow from all
        AddHandler cgi-script .cgi .pl
    </Directory>

</IfModule>
 
Old 02-25-2003, 06:13 PM   #13
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
That works! So now what should I do?

Thanks

EDIT: Also, the reason that it worked is because I REMed out the ScriptAlias. I tried to put it back in but I got a 404 error.

Last edited by ApacheMan252; 02-25-2003 at 06:18 PM.
 
Old 02-25-2003, 06:15 PM   #14
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
Also, when I go to it, and I click on a .pl file, I get a 500 Internal Server Error.
 
Old 02-25-2003, 06:31 PM   #15
English Guy
LQ Newbie
 
Registered: Feb 2003
Posts: 6

Rep: Reputation: 0
did you include the AddHandler cgi-script .cgi .pl within the <Directory> tags? Is the .pl file the same permissions as the .cgi file?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI and Apache Sevoma Linux - Software 7 02-06-2005 06:55 PM
about Apache and CGI kpachopoulos General 1 11-17-2004 05:23 PM
apache v2.0.44 + cgi ; securing cgi-support in apache markus1982 Linux - General 0 01-20-2003 02:03 PM
apache-cgi j-ray Linux - Software 1 12-12-2002 04:31 PM
About cgi , pl. in apache.... raymond Linux - General 1 11-11-2002 10:22 AM


All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration