Apache2 Errors

From Utopia
Jump to navigation Jump to search


Invalid command 'PythonHandler'

Genauer Fehler

Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration


Vorgehen

gucken ob die Datei da ist:

cat mods-available/python.load

LoadModule python_module /usr/lib/apache2/modules/mod_python.so


gucken ob die .so da ist:


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


Bei mir war die Zeile "LoadModule" komischerweise auskommentiert. Wenn ich sie wieder einkommentiere, dann startet Apache2 nicht mehr, ohne Fehlermeldung. Er sagt einfach


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: https://httpd.apache.org/docs/2.4/

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.


Die error.log von Apache2 meinte daraufhin:


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 libapache2-mod-python libapache2-mod-python-doc


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... :)