Python: Difference between revisions

From Utopia
Jump to navigation Jump to search
(Replaced content with " == Web Programmierung == === WSGI === Ist die Schnittstelle zwischen Python Code, und dem Webserver... === WSGI/Apache2 Modul === apt-get install libapache2-mod-wsgi-py3 a2enmod wsgi === Apache Fehler === Apache2 Errors")
Tags: Replaced Visual edit
Line 3: Line 3:


== Web Programmierung ==
== Web Programmierung ==


=== WSGI ===
=== WSGI ===
Ist die Schnittstelle zwischen Python Code, und dem Webserver...
=== WSGI/Apache2 Modul ===




Line 12: Line 16:
a2enmod wsgi  
a2enmod wsgi  


=== Apache2 ===
==== Benoetigte Apache Module ====
<code>libapache2-mod-python</code>
* Python-embedding module for Apache 2
==== Optionale Apache Module ====
libapache2-mod-python-doc


* Python-embedding module for Apache 2 - documentation<br />




 
=== Apache Fehler ===
==== Apache Fehler ====
 
[[Apache2 Errors]]
[[Apache2 Errors]]
'''<u><big>Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration</big></u>'''
<u>gucken ob die Datei da ist:</u>
cat mods-available/python.load
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
<u>gucken ob die .so da ist:</u>
'''ll /usr/lib/apache2/modules/mod_python.so'''
-rw-r--r-- 1 root root 143K Jun 28  2013 /usr/lib/apache2/modules/mod_python.so
<u>Bei mir war die Zeile "LoadModule" komischerweise auskommentiert. Wenn ich sie wieder einkommentiere, dann startet Apache2 nicht mehr, ohne Fehlermeldung. Er sagt einfach</u>
'''service apache2 restart'''
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
'''systemctl status apache2.service'''
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2023-05-06 17:03:31 CEST; 7s ago
Docs: <nowiki>https://httpd.apache.org/docs/2.4/</nowiki>
Process: 21674 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
systemd[1]: Starting The Apache HTTP Server...
apachectl[21674]: Action 'start' failed.
apachectl[21674]: The Apache error log may have more information.
systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
systemd[1]: apache2.service: Failed with result 'exit-code'.
[systemd[1]: Failed to start The Apache HTTP Server.
<u>Die error.log von Apache2 meinte daraufhin:</u>
'''tail -n 100 /var/log/apache2/error.log'''
[wsgi:crit] [pid 21542] mod_wsgi (pid=21542): The mod_python module can not be used in conjunction with mod_wsgi 4.0+. Remove the mod_python module from the Apache configuration.
AH00016: Configuration Failed
Problem herausgefunden:
mod_wsgi und mod_python arbeiten in der aktuellen Version nicht mehr zusammen. Es gab irgendwie Probleme mit dem Thread-Management der C-Lib... Die Lösung soll ein
Zitat: "...you shouldn't be using mod_python any more. Use a proper Python web framework with a more modern template system instead."
Wikipedia sagt dazu:
"Eine konzeptionelle Weiterentwicklung von mod_python ist mod_wsgi."
Also erstmal das mod_python ausradieren... :)
'''apt-get purge <code>libapache2-mod-python libapache2-mod-python-doc</code>'''
dann die apache2 config meiner Seite anpassen:
Laut des Quick Configuration Guides https://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html einfach nen Skript-Alias einbauen
'''vi /etc/apache2/sites-available/subdomain.domain.tld'''
<VirtualHost *:80>
  ServerName subdomain.domain.tld
  ServerAlias domain.tld  *.domain.tld
  DocumentRoot /var/www/subdomain.domain.tld
  WSGIScriptAlias / /var/www/subdomain.domain.tld /index.wsgi
</VirtualHost>
Apache neu starten
'''service apache2 restart'''
und TADAAAAAAA... :)

Revision as of 19:15, 6 May 2023


Web Programmierung

WSGI

Ist die Schnittstelle zwischen Python Code, und dem Webserver...

WSGI/Apache2 Modul

apt-get install libapache2-mod-wsgi-py3

a2enmod wsgi



Apache Fehler

Apache2 Errors