Python AddOn fehlt.

Irgendwelche Probleme mit XAMPP für Windows? Dann ist hier genau der richtige Ort um nachzufragen.

Python AddOn fehlt.

Postby GerMa » 18. April 2007 08:14

Laut apachefriends - Website müsste es ein offizielles Python-AddOn für XAMPP für Windows geben.
Jedoch sind auf der Seite http://www.apachefriends.org/de/xampp-windows.html nur Addons für Perl und Tomcat zu finden.
Zwar gibt es auf http://sourceforge.net/projects/xamppaddon ein Python-Addon zum herunterladen. Dieses datiert jedoch von 2005.
Weiß jemand, ob und wo es ein aktuelles Python-Addon für XAMPP für Windows gibt, welches mit Apache 2.2 und Python 2.5 bzw. der aktuellen XAMPP-Version 1.6.0a läuft?
GerMa
 
Posts: 1
Joined: 18. April 2007 08:03

One must install Python support by your own

Postby germareyam » 25. January 2008 15:42

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. Copy the Python script TestPython.py (see bottom of this file)
into the C:\xampp\cgi-bin directory


7. Enter the adress http://localhost/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()
germareyam
 
Posts: 10
Joined: 18. January 2008 08:21
Location: D-89522 Heidenheim / Brenz

Postby germareyam » 04. February 2008 11:39

Hier noch eine kleine Ergänzung:
In Punkt 6 sollte man nicht die *.py - Dateien nach cgi-bin kopieren, sondern die bereits kompilierten *.pyc - Dateien. Ansonsten wird nur der Inhalt, d.h. der Sourcecode des *.py - Skripts angezeigt. Wieso das unter Windows nicht automatisch passiert, wie in Linux weiß ich leider auch nicht.
Aber vielleicht weiß ja irgendjemand eine Antwort hierauf.
Die *.pyc - Dateien erzeuge ich mir mit einem kleinen Skript, das ich einmal ausführen, z.B. zum Erzeugen von TestPython.pyc:

#!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()

Gruß
Gerhard Mayer
germareyam
 
Posts: 10
Joined: 18. January 2008 08:21
Location: D-89522 Heidenheim / Brenz


Return to XAMPP für Windows

Who is online

Users browsing this forum: No registered users and 64 guests