Apache & Python 500 Error
Peter van Kampen
peterka at xs3.xs4all.nl
Thu Feb 3 08:18:07 EST 2005
On 2005-02-02, Christian <stonis at hotmail.com> wrote:
> Hello,
>
> i have an apache 1.3 server with python on debian. Python works fine but
> the scripts wont´t work.
>
> This easy script i want to do on apache:
>
> #!/usr/bin/python
> import os
> os.getcwd()
>
> in apache config i have done this:
>
><Directory /var/www/python>
> AddHandler python-program .py
> PythonHandler python
> Order allow,deny
> Allow from all
> #PythonDebug On
></Directory>
>
> the script is in this directory /var/www/python
>
> but i get an 500 error everytime, with "every" script
You're confusing mod_python and cgi. And you're cgi isn't written
properly...
Try this to enable cgi for python files:
<Directory /var/www/python>
Options +ExecCGI
AddHandler cgi-script py
</Directory>
Don't forget to restart apache.
A proper cgi-file outputs a header with at least the content-type. A
header is followed by an empty line.
#!/usr/bin/env python
import os
print "Content-type: text/html"
print
print os.getcwd()
--
Peter van Kampen
pterk -- at -- datatailors.com
More information about the Python-list
mailing list