Connecting Tech Pros Worldwide Help | Site Map

Configuring Apache to see my CGI scripts. Unable to run CGI.

Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#1: Sep 8 '07
My cgi script is not being seen by Apache. I have no idea what to do,

1) I have read the httpd file in my conf folder and still no luck.

2) I have placed my CGI place in

C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/

still not luck.

My shebang line in my CGI is: #!/usr/bin/perl
Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#2: Sep 9 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


In the conf folder (httpd) what do i need to delete/change below to run my CGI scripts. I've tried 'Allow from all' however this did not work too.

Currently all my .cgi files are in /Apache2.2/cgi-bin.

The below code taken from httpd doc (in conf folder):

Expand|Select|Wrap|Line Numbers
  1. # "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin" should be changed to whatever your ScriptAliased
  2. # CGI directory exists, if you have that configured.
  3. #
  4. <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
  5.     AllowOverride None
  6.     Options None
  7.     Order allow,deny
  8.     Allow from all
  9. </Directory>
my ScriptAlias is as follows:

ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"
Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#3: Sep 12 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


changed the shebang which actually resolved the issue. Changed the shebang line to point to perl.exe
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Sep 12 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


Heya, Patel.

Have a look at this document.
Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#5: Sep 13 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


pbmods,

I get the error: HTTP 404 - File not found.

I have followed every thing from the link you gave me, still not sure what the problem is, i think I'm going crazy.

It's 3.25am i think i need to go to bed now.

cheers
Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#6: Sep 13 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


pdmos,

1) my initial url is: http://localhost/post.html

i fill out the form (post.html) and click Submit which takes me to:

2) http://localhost/cgi-bin/post2.cgi

It's here on the above URL i get the error 404

Post.html is located in apache2.2/htdoc folder and post2.cgi is location in apache2.2/cgi-bin/post2.cgi

cheers
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#7: Sep 13 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


Heya, Patel.

pdmos. That's a good one.

You should have this line somewhere in your httpd.conf file:
Expand|Select|Wrap|Line Numbers
  1. ScriptAlias /cgi-bin/ "/path/to/apache2/cgi-bin/"
  2.  
Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#8: Sep 13 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


this is the line i have:

ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"


pbmods, i can run .cgi files from this above folder by typing the following in the browser:

http://localhost/cgi-bin/browser.cgi
http://localhost/cgi-bin/hello.cgi

however the problem is when i SENT a form to a .cgi is where i get the 404 error.

cheers mate
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#9: Sep 13 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


Heya, Patel.

Post an example of a form tag that doesn't go where it's supposed to on submit.
Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#10: Sep 13 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


Hey pbmos,

My post.html FORM tag is as follows:

[HTML]<form action="/cgi-bin/post2.cgi" method="POST">[/HTML]
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#11: Sep 13 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


Heya, Patel.

I assume that you do not get a 404 if you navigate to http://localhost/cgi-bin/post2.cgi in your browser....

You didn't mention post2.cgi as one of the scripts that you tested in an earlier post, so I thought I'd just make sure.
Familiar Sight
 
Join Date: May 2007
Location: Milton Keynes, England
Posts: 135
#12: Sep 14 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


pbmods, guess what it's resolved. The problem was very simple, my CGI was named post2.cgi.cgi hence the FORM couldn't find the file.

Thank very much again, now starts my Perl journey.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#13: Sep 14 '07

re: Configuring Apache to see my CGI scripts. Unable to run CGI.


Heya, Patel.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Reply