Using .cgi/.pl to enable CGI script in Apache

Using .cgi/.pl to enable CGI script in Apache

Post by Gary Whitt » Sat, 05 Apr 1997 04:00:00



I am trying to run CGI scripts local to the companion HTML documents
using the Apache server and Linux. According to the manual if I add the
lines:

AddType application/x-httpd-cgi cgi pl
AddType application/x-httpd-cgi .cgi .pl
 (yeah - I wasn't sure whether or not to include the "." so I tried it
  both ways)

to the srm.conf and restart the server, that should do it.

Not true.

I get:
***********************************************************************
        Forbidden

You don't have permission to access /chamFarm/CFemail.pl on this server.
***********************************************************************

(where CFemail.pl is the script in the HTML home directory "chamFarm"
- as expected)

 the script has 777 permissions just to enable all possible
permissions.

If I take the lines out of the srm.conf file and restart the server, I
get:

***********************************************************************
Method not implemented

POST to /chamFarm/CFemail.pl not supported.
***********************************************************************
 which, I guess, is the sort of error you might expect.

So I don't see the problem. This should be very straightforward. Does
anyone have any ideas?

        Thanks for your time,
                Gary Whitten

 
 
 

Using .cgi/.pl to enable CGI script in Apache

Post by Daniel Fo » Sat, 05 Apr 1997 04:00:00



> I am trying to run CGI scripts local to the companion HTML documents
> using the Apache server and Linux. According to the manual if I add the
> lines:

> AddType application/x-httpd-cgi cgi pl
> AddType application/x-httpd-cgi .cgi .pl
>  (yeah - I wasn't sure whether or not to include the "." so I tried it
>   both ways)

>         Thanks for your time,
>                 Gary Whitten


You also need:

AddHandler cgi-script .cgi .pl

--
Daniel Fox


 
 
 

Using .cgi/.pl to enable CGI script in Apache

Post by Paul Sutto » Sun, 06 Apr 1997 04:00:00



Quote:> I am trying to run CGI scripts local to the companion HTML documents
> using the Apache server and Linux. According to the manual if I add the
> lines:
> AddType application/x-httpd-cgi cgi pl
> AddType application/x-httpd-cgi .cgi .pl
>  (yeah - I wasn't sure whether or not to include the "." so I tried it
>   both ways)

> to the srm.conf and restart the server, that should do it.
> Not true.

Have a look in your error_log. It should tell you exactly what is wrong.
By the way the dots (periods) are optional.

Paul
--
Paul Sutton, Technical Director, UK Web --- http://www.ukweb.com/~paul/
Apache Week: Latest news on Apache server... http://www.apacheweek.com/

 
 
 

Using .cgi/.pl to enable CGI script in Apache

Post by Paul Sutto » Sun, 06 Apr 1997 04:00:00





> > I am trying to run CGI scripts local to the companion HTML documents
> > using the Apache server and Linux. According to the manual if I add the
> > lines:
> > AddType application/x-httpd-cgi cgi pl
> > AddType application/x-httpd-cgi .cgi .pl
> >  (yeah - I wasn't sure whether or not to include the "." so I tried it
> >   both ways)

> You also need:
> AddHandler cgi-script .cgi .pl

No. The AddHandler and AddType directives are independent. AddType
is the old way of specifying special behaviour for particular extensions.
What AddType really does is associate a "mime type" with a particular
extension.
This is normally something like "text/html" or "image/gif". However
some values have special meaning to Apache - in this case
"application/x-httpd-cgi"
tells Apache to treat this extension as a CGI program. This are called
"magic mime types" because they are treated as a mime type, but aren't
really.

Recent versions of Apache (1.0 onwards) provide a much neater way of
setting
special behaviour, using AddHandler as in your example. You only need one
or the other of AddType and AddHandler for a particular extension.
More information on handlers is available at
http://www.apache.org/docs/handler.html

Paul
--
Paul Sutton, Technical Director, UK Web --- http://www.ukweb.com/~paul/
Apache Week: Latest news on Apache server... http://www.apacheweek.com/

 
 
 

Using .cgi/.pl to enable CGI script in Apache

Post by Amazing Online Marketin » Wed, 09 Apr 1997 04:00:00


I'm having similiar problems.  I can get ScriptAlias to run cgi's in
cgi-bin, but no manner of tweaking seems to be able to get cgi's to run
elsewhere in the HTML document root.

# To use CGI scripts:
#AddHandler cgi-script .cgi
AddHandler cgi-script cgi
#AddHandler application/x-httpd-cgi .cgi
#AddHandler application/x-httpd-cgi cgi
#AddType  application/x-httpd-cgi .cgi
#AddType  application/x-httpd-cgi cgi
#AddType  application/x-httpd-cgi CGI

I"ve tried all these combinations, but none seems to work.  I've been
kill -15'ing the root httpd process and restarting it.  I have no idea
what I'm doing wrong.

I'm trying to use my FreeBSD host as a beta web server for our virtual
host at www.amz.com.  They've been letting us execute CGI's from any
directory so our programmer created CGI's all over the place and it
would take quite some effort at this point to port them all into the
cgi-bin directory.  Anyone have a clue about what I'm doing wrong here?





> > > I am trying to run CGI scripts local to the companion HTML documents
> > > using the Apache server and Linux. According to the manual if I add the
> > > lines:
> > > AddType application/x-httpd-cgi cgi pl
> > > AddType application/x-httpd-cgi .cgi .pl
> > >  (yeah - I wasn't sure whether or not to include the "." so I tried it
> > >   both ways)

> > You also need:
> > AddHandler cgi-script .cgi .pl

> No. The AddHandler and AddType directives are independent. AddType
> is the old way of specifying special behaviour for particular extensions.
> What AddType really does is associate a "mime type" with a particular
> extension.
> This is normally something like "text/html" or "image/gif". However
> some values have special meaning to Apache - in this case
> "application/x-httpd-cgi"
> tells Apache to treat this extension as a CGI program. This are called
> "magic mime types" because they are treated as a mime type, but aren't
> really.

> Recent versions of Apache (1.0 onwards) provide a much neater way of
> setting
> special behaviour, using AddHandler as in your example. You only need one
> or the other of AddType and AddHandler for a particular extension.
> More information on handlers is available at
> http://www.apache.org/docs/handler.html

> Paul
> --
> Paul Sutton, Technical Director, UK Web --- http://www.ukweb.com/~paul/
> Apache Week: Latest news on Apache server... http://www.apacheweek.com/

--

Amazing Online Marketing          Custom Built Web Sites, Soup to nuts
fax: 503.284.6191                       Forms, scripts, graphics, etc.
 
 
 

Using .cgi/.pl to enable CGI script in Apache

Post by Keith Brow » Wed, 09 Apr 1997 04:00:00




> > I am trying to run CGI scripts local to the companion HTML documents
> > using the Apache server and Linux. According to the manual if I add the
> > lines:

> > AddType application/x-httpd-cgi cgi pl
> > AddType application/x-httpd-cgi .cgi .pl
> >  (yeah - I wasn't sure whether or not to include the "." so I tried it
> >   both ways)

> >         Thanks for your time,
> >                 Gary Whitten

> You also need:

> AddHandler cgi-script .cgi .pl

  I've tried all these things and *nothing* I do works. Right now I have
ScriptAlias set to my cgi directory and when I run my test program

#!/usr/bin/perl
# test perl program

 print("Content type: text/html\n\n");
 print("<html><body><h1><center>test\n</center></h1></body></html>");

I get the text of the test program not the intended output. If I set
AddType to 'application/x-httpd-cgi .pl' I get the same result. When I use
'AddHandler script-cgi pl' the *second* print statement is executed to
give:

<html><body><h1><center>test
</center></h1></body></html>

Why doesn't it work??

Keith

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
-                                                                     -


-    University of Saskatchewan  http://chem4823.usask.ca/kbrown.html -  
-    Saskatoon, SK                                                    -
-                                                                     -
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
-                        OS: Linux 2.0.29                             -
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
-                                                                     -
-     'I am Homer of Borg. Resistance is ... hmmm ... donuts!'        -
-                                                                     -
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-