[Tutor] configure python with apache on mandrake 8.0

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sun, 10 Mar 2002 23:34:55 -0800 (PST)


On Mon, 11 Mar 2002, gopal anshary                                               wrote:

> hello every body
>
> i wanna ask about how to configure python with apache on mandrake 8.0,
> in order to run my script. because in /etc/httpd/conf/httpd.conf
> there's only have httpd.conf. they dont have access.conf and smr.conf
> . that's all for now i wait for your answer?

Hi Gopal,


If you keep your scripts in the standard 'cgi-bin' directory in Apache,
you actually don't need to do much else except plop the Python scripts in
there.  You'll want to make sure that that the scripts are executable, and
that the 'magic line'

###
#!/usr/bin/python
###

is pointing toward the path where Python is installed on your system.  
Otherwise, that should be it.  *grin*

Also, be sure to use some error-trapping to make it easier to debug your
CGI scripts.  If you have Python 2.2, the 'cgitb' module might just be the
ticket:

    http://www.python.org/doc/current/lib/module-cgitb.html


If you want to allow Python scripts to be generally executable, you'll
want to make a few changes to the httpd.conf.  You'll want to mark off
directories with the 'ExecCGI' directive.

Also, you may want to tell Apache to allow '.py' as a file extension for
CGI scripts.  Look for the "AddHandler cgi-script", and add '.py' into the
list of acceptable extensions.  For example, here's what it looks like on
my laptop:

###
AddHandler cgi-script .cgi .sh .pl .py
###


There are more details on CGI's and Python here:

    http://starship.python.net/crew/davem/cgifaq/faqw.cgi?req=index


Please feel free to ask more questions about this.  Best of wishes to you!