URL: https://www.overclockers.at/coding-stuff/mod_python_win32_apache_2_2_4_installation_188199/page_1 - zur Vollversion wechseln!
Grüß euch!
Ich habe nicht direkt eine Coding-Frage, sondern eher eine Installationsfrage, ich hoffe trotzdem, daß ich hier damit richtig bin.
Also, ich habe einen Apachen unter Windows 2000 laufen, Version ist 2.2.4. Erst gestern habe ich es mir angetan, mod_perl 2.0.3 mit ActivePerl 5.8.8 zum Laufen zu bewegen, und heute dachte ich mir, Zeit für Python Support!
Also installiert habe ich Python 2.5.1, und das Modul mod_python 3.3.1 für Python 2.5.x und Apache 2.2.x.
Was ich jetzt offenbar noch nicht richtig mache, ist die httpd.conf Konfiguration. Sieht bei mir momentan wie folgt aus (ich filtere nach Fileextension)...
Snippet:
Code:LoadModule python_module modules/mod_python.so [...] AddHandler python-program .py <Files ~ "\.py$"> SetHandler python-program PythonHandler test </Files>
Code:[error] [client 0.0.0.0] mod_python (pid=4172, interpreter='<url-zensiert>', phase='PythonHandler', handler='test'): Application Error [error] [client 0.0.0.0] ServerName='<url-zensiert>' [error] [client 0.0.0.0] DocumentRoot: '<Filesystempfad-zensiert>' [error] [client 0.0.0.0] URI: '/thrawn/test.py' [error] [client 0.0.0.0] Location: None [error] [client 0.0.0.0] Directory: None [error] [client 0.0.0.0] Filename: '<Filesystempfad-zensiert>' [error] [client 0.0.0.0] PathInfo: '' [error] [client 0.0.0.0] Traceback (most recent call last): [error] [client 0.0.0.0] File "C:\\Server\\Python25\\Lib\\site-packages\\mod_python\\importer.py", Line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent) [error] [client 0.0.0.0] File "C:\\Server\\Python25\\Lib\\site-packages\\mod_python\\importer.py", Line 1202, in _process_target\n module = import_module(module_name, path=path) [error] [client 0.0.0.0] File "C:\\Server\\Python25\\Lib\\site-packages\\mod_python\\importer.py", Line 304, in import_module\n return __import__(module_name, {}, {}, ['*']) [error] [client 0.0.0.0] ImportError: No module named test
Code:from mod_python import apache def handler(req): req.content_type = 'text/plain' req.write("Hallo %s!"%(req.args,)) return apache.OK
was du wahrscheinlich willst ist den publisher-handler um alle .py dateien aufrufen zu können. gib einfach folgenden code in deine httpd.conf:
das passende file "hello.py" braucht dann folgenden inhalt:Code:AddHandler python-program .py PythonHandler mod_python.publisher PythonDebug On
ein aufruf erfolgt per:Code:def say(req, what="NOTHING"): return "I am saying %s" % what
oder noch besser:Code:http://meinhost/hello.py/say
hier ist übrigens noch ein bisschen lesestoff: http://www.modpython.org/live/curre...-pub-intro.htmlCode:http://meinhost/hello/say?what=o.v.e.r.clockers.at%20FTW
Vielen Dank, so hat's geklappt! Ist ja konfigurationstechnisch und auch vom Aufruf her ziemlich ungewohnt, aber es haut Mal hin!
wahrscheinlich wurde deine .htaccess nicht gelesen. "AllowOverride FileInfo" für das verzeichnis hätte dir auch geholfen.
overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2024