Hallo,
das letzte AddOn war für Python 2.3.
Für neuere XAMPP- und Python-Versionen muß man leider alles von Hand konfigurieren:
One possibility is to install the Python stuff by hand. Following is the procedure:
1. Download the latest XAMPP (version 1.6.5) from
http://www.apachefriends.de
or
http://www.apachefriends.org and install it in the C:\xampp directory
2. Download Python 2.5.1 from
http://www.python.org
and install it in the C:\Python25 directory
3. Download mod_python (version 3.3.1) from
http://www.modpython.org
and install it.
Choose the C:\Python25 directory for the Python location
and C:\xampp\apache directory as the Apache location
4. Open the file C:\xampp\apache\conf\httpd.conf
and add the line
LoadModule python_module modules/mod_python.so
at the end of the other LoadModule lines
Also add the following lines
<Directory "C:/xampp/cgi-bin">
AddHandler mod_python .py
PythonHandler python
PythonDebug On
Order allow,deny
Allow from all
</Directory>
5. Stop and restart the Apache server with the XAMPP Control Panel
If the Apache server doesn't start you made an error in the file
C:\xampp\apache\conf\httpd.conf
6. Compile the the Python script TestPython.py (see bottom of this file) and
copy the file TestPython.pyc into the C:\xampp\cgi-bin directory
For compilation you can use the following script:
#!C:\Python25\python -u
# -*- coding: iso-8859-15 -*-
import cgi,cgitb,sys
from TestPython import *
class CompilePythonModules():
""" Compiles the needed Python modules. """
def __init__(self):
""" Constructor method. """
if __debug__:
cgitb.enable() # for CGI debugging
sys.stderr = sys.stdout
def _compile(self):
""" Compiles the needed modules. """
tstPython = TestPython()
# main program starts here
if __name__ == '__main__':
cPyMod = CompilePythonModules()
cPyMod._compile()
I don't know why one has to compile the Python scripts "by hand".
If I copy only the file TestPython.py then I get back the content of my python
script in the next step 7. I don't know the reason for this behaviour.
Under Linux the Apache server automatically compiles the Python script.
Maybe someone knows an answer for this strange bahaviour under Windows.
But my workaround works fine.
7. Enter the adress
http://localhost/cgi-bin/TestPython.py into your web browser
Content of the script TestPython.py:
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import cgi,cgitb,Cookie,sys
class TestPython():
""" Tests if the XAMPP Python Add-On and mod_python are properly installed. """
def __init__(self):
""" Constructor method. """
if __debug__:
cgitb.enable() # for CGI debugging
sys.stderr = sys.stdout
def _outputHTMLGreetingPage(self):
""" Outputs an HTML response to the browser. """
print "Content-type: ", "text/html"
print ""
print "<?xml version=1.1 ?>"
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"'
print '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
print '<html xmlns="http://www.w3.org/1999/xhtml">'
print " <head>"
print " <title>My window title</title>"
print " </head>"
print " <body>"
print " <h1>Congatulation, Python works!</h1>"
print " </body>"
print "</html>"
# main program starts here
if __name__ == '__main__':
test = TestPython()
test._outputHTMLGreetingPage()
Gruß
Gerhard Mayer