Seite 1 von 2
mod_python und django
Verfasst: Samstag 20. September 2008, 13:57
von nemomuk
Hallo,
ich versuche gerade auf meinem Debian Server Django zum laufen zu bringen:
Code: Alles auswählen
MOD_PYTHON ERROR
ProcessId: 4545
Interpreter: 'debian.debian.local'
ServerName: 'debian.debian.local'
DocumentRoot: '/var/www/'
URI: '/django/'
Location: None
Directory: '/var/www/django/'
Filename: '/var/www/django/'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1202, in _process_target
module = import_module(module_name, path=path)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 304, in import_module
return __import__(module_name, {}, {}, ['*'])
ImportError: No module named core.handlers.modpython
Meine Config:
Code: Alles auswählen
<Directory "/var/www/django/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE django.settings
PythonOption django.root /django
PythonDebug On
PythonPath "['/var/www/', '/usr/local/django-apps/'] + sys.path"
</Directory>
Ich weiß nicht mehr weiter und hab mir auch schon die Doku zu modpython bei Django angeschaut... Ich weiß nur nicht, wie ich PythonPath ändern muss, damit es funktioniert...
Habt ihr eine Idee?
Re: mod_python und django
Verfasst: Samstag 20. September 2008, 16:20
von Leonidas
SchneiderWeisse hat geschrieben:Habt ihr eine Idee?
mod_python wegwerfen, das ist Schrott. Bis auf die Django-Leute haben es wohl inzwischen auch alle mitbekommen.
Verfasst: Samstag 20. September 2008, 17:14
von Sr4l
1. Checken mit welcher Python Version modpython läuft und ob dort django installiert ist
2. core.handlers.modpython die Datei dazu suchen und PythonPath mitgeben
finden solltest du das so:
Code: Alles auswählen
/var/lib/python-support/python2.4/django/core/handlers
sollte dann raus kommen
langfristig kannst du auf mod-wsgi (
http://modwsgi.org/ ) umsteigen.
mfG
Verfasst: Samstag 20. September 2008, 22:48
von Leonidas
Alternarnativ auch kurzfristig. Ich habe auch mit FastCGI gute Erfahrungen gemacht, das funktioniert unter jedem brauchbaren HTTPd.
Verfasst: Samstag 20. September 2008, 23:54
von nemomuk
Problem: mod_wsgi ist nicht im stable von Debian und usntable will ich nicht mit auf den Server packen. Deswegen vorerst mod_python und später mod_wsgi, wenn es im stable ist.
Vielen Dank!
Verfasst: Sonntag 21. September 2008, 00:00
von Leonidas
SchneiderWeisse hat geschrieben:Problem: mod_wsgi ist nicht im stable von Debian und usntable will ich nicht mit auf den Server packen. Deswegen vorerst mod_python und später mod_wsgi, wenn es im stable ist.
Sowohl libapache2-mod-fcgid sowie libapache2-mod-fastcgi sind es. Das ist unter anderem der Grund warum ich ersteres nutze (in stable
und in main).
Verfasst: Sonntag 21. September 2008, 11:25
von nemomuk
Danke,
libapache2-mod-fastcgi ist leider nich im stable, zumindest nicht bei mir...
Code: Alles auswählen
debian:~# apt-cache search fastcgi
libcgi-fast-perl - CGI::Fast Perl module
lighttpd - A fast webserver with minimal memory footprint
php4-cgi - server-side, HTML-embedded scripting language (CGI binary)
libapache-mod-scgi - Apache module implementing the SCGI protocol
libapache2-mod-fcgid - an alternative module compat with mod_fastcgi
libapache2-mod-scgi - Apache module implementing the SCGI protocol
libcgicc-doc - A C++ class library for writing CGI applications
libcgicc1 - A C++ class library for writing CGI applications
libcgicc1-dev - A C++ class library for writing CGI applications
libembperl-perl - A system for building dynamic websites with Perl
libfcgi-dev - Header files of FastCGI
libfcgi-perl - FastCGI Perl module
libfcgi-procmanager-perl - Functions for managing FastCGI applications.
libfcgi-ruby1.8 - FastCGI library for Ruby
libfcgi0c2 - Shared library of FastCGI
libnora-ruby1.8 - Web Application Library for ruby
libocamlnet-ocaml - OCaml application-level Internet protocols and conventions library
libocamlnet-ocaml-dev - OCaml application-level Internet protocols and conventions library
python-flup - Implements Python Web Server Gateway Interface (WSGI)
python-scgi - Server-side implementation of the SCGI protocol
Und fcgid unterstützt kein FastCGIExternalServer soweit ich das in Erfahrung bringen konnte...
Oder mache ich hier was komplett falsch?^^
Vielen Dank!
Verfasst: Sonntag 21. September 2008, 13:18
von Leonidas
SchneiderWeisse hat geschrieben:Danke,
libapache2-mod-fastcgi ist leider nich im stable, zumindest nicht bei mir...
Es ist in Stable nur nicht in main, so wie fcgid, sondern in non-free.
Aber den FastCGIExternalServer braucht man doch gar nicht. Ich poste hier mal, wie mein Setup mehr oder weniger aussieht:
/etc/apache2/mods-enabled/fcgid.conf hat geschrieben:<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
SocketPath /var/lib/apache2/fcgid/sock
IPCConnectTimeout 20
</IfModule>
/etc/apache2/sites-enabled/bugs hat geschrieben:<VirtualHost *>
ServerName my.vhost.de
# route all requests on this host to the tracker script
Alias / /var/www/tracker/tracker.fcgi/
# run it as username, group groupname
SuexecUserGroup username groupname
<Directory /var/www/tracker/>
Options FollowSymLinks ExecCGI
AllowOverride None
# add HTTP basic auth
AuthType Basic
AuthName "Bugtracker"
AuthUserFile /etc/apache2/htpasswd
Require valid-user
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
Verfasst: Sonntag 21. September 2008, 14:45
von nemomuk
Vielen Dank!
Ich habe jetzt mal versucht das Ganze zum Laufen zu bringen... schaffe es aber nicht - bin nicht so der Apache Guru... Hier mal die Infos, ich bekomme immer einen 404 Error Not Found, wenn ich die IP aufrufe, theoretisch müsste ich doch eine Seite wie diese hier sehen
http://www.galileocomputing.de/openbook ... rojekt.gif ...:
Code: Alles auswählen
debian:/var/www/pytest# cat /etc/apache2/sites-available/default
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/pytest/
Alias / /var/www/pytest/pytest.fcgi/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/pytest/>
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel debug
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
debian:/var/www/pytest# ls -la
total 32
drwxr-xr-x 2 root root 4096 Sep 21 15:25 .
drwxr-xr-x 5 root root 4096 Sep 21 11:50 ..
-rwxrwxrwx 1 root root 0 Sep 21 11:50 __init__.py
-rwxrwxrwx 1 root root 117 Sep 21 11:52 __init__.pyc
-rwxrwxrwx 1 root root 320 Sep 21 15:05 fcgi.py
-rwxrwxrwx 1 root root 542 Sep 21 11:50 manage.py
-rwxrwxrwx 1 root root 2394 Sep 21 11:50 settings.py
-rwxrwxrwx 1 root root 1792 Sep 21 11:52 settings.pyc
-rwxrwxrwx 1 root root 234 Sep 21 11:50 urls.py
debian:/var/www/pytest# cat fcgi.py
import sys, os
# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "pytest.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
Verfasst: Sonntag 21. September 2008, 14:56
von Leonidas
Warum ist denn bei dir alles +x gesetzt? Es muss doch nur der FastCGI-Entrypoint Ausführbar sein.
Außerdem: hast du es FCGId eingeschaltet? Hast du es entsprechend konfiguriert? Du hast den ServerName nicht gesetzt. DocumentRoot brauchst du nicht mehr, das wird nämlich vom Alias überdeckt. Den ersten <Directory>-Eintrag brauchst du auch nicht, der ist ja auch überdeckt. Hast du den Server neu geladen?
Was sagt außerdem die Logdatei?
Verfasst: Sonntag 21. September 2008, 15:02
von nemomuk
Vielen Dank!
So habe nun die Sachen verbessert in der default
Code: Alles auswählen
debian:/var/www/pytest# cat /etc/apache2/httpd.conf
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
SocketPath /var/lib/apache2/fcgid/sock
IPCConnectTimeout 20
</IfModule>
debian:/var/www/pytest# cat /etc/apache2/sites-available/default
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
Servername pytest.local
Alias / /var/www/pytest/pytest.fcgi/
<Directory /var/www/pytest/>
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel debug
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
Der Access-Log sagt nur:
Code: Alles auswählen
192.168.2.36 - - [21/Sep/2008:15:40:22 +0200] "GET / HTTP/1.1" 404 294 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"
und im error-log steht gar nichts...
Verfasst: Sonntag 21. September 2008, 15:03
von Leonidas
Die Seite ist schon aktiviert und das Modul wird schon geladen, oder? Du greibst auch via diesem Namen auf den Server zu?
Verfasst: Sonntag 21. September 2008, 15:07
von nemomuk
Code: Alles auswählen
debian:/etc/apache2/mods-enabled# ls
alias.load authn_file.load authz_groupfile.load authz_user.load cgi.load dir.load fcgid.conf mime.load php5.conf rewrite.load status.load
auth_basic.load authz_default.load authz_host.load autoindex.load dir.conf env.load fcgid.load negotiation.load php5.load setenvif.load
debian:/etc/apache2/mods-enabled# cat fcgid.load
LoadModule fcgid_module /usr/lib/apache2/modules/mod_fcgid.so
debian:/etc/apache2/sites-enabled# cat 000-default
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
Servername pytest.local
Alias / /var/www/pytest/pytest.fcgi/
<Directory /var/www/pytest/>
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel debug
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
Nein ich greife direkt über die lokale IP auf den Server zu... da das hier alles noch lokal auf einem Testrechner läuft.
Verfasst: Sonntag 21. September 2008, 15:15
von Leonidas
SchneiderWeisse hat geschrieben:Nein ich greife direkt über die lokale IP auf den Server zu... da das hier alles noch lokal auf einem Testrechner läuft.
Dann brauchst du dich auch nicht zu wundern warum der VHost nicht greift, schließlich schicht der Browser dann auch keinen Host-Header.
Verfasst: Sonntag 21. September 2008, 17:32
von nemomuk
diese Aussage kann ich nicht nachvollziehen, was höchstwahrscheinlich an mir liegt...
Ich habe testweise einfach mal das hier gemacht:
Code: Alles auswählen
debian:~# cat /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerName debian.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/pytest/
# Alias / /var/www/pytest/pytest.fcgi/
<Directory /var/www/pytest/>
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel debug
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
Und habe eine Datei in var/www/pytest und sie wird einwandfrei angezeigt... Nur komischerweise zeigt er nichts an beim Django Project.
Verfasst: Sonntag 21. September 2008, 18:34
von Leonidas
Achja, hast du flup installiert?
Verfasst: Sonntag 21. September 2008, 20:45
von nemomuk
ja habe ich...
ein import flub funktioniert auch einwandfrei...
Verfasst: Montag 22. September 2008, 12:09
von Leonidas
Was steht im error_log zum Thema mod_fcgid drinnen?
Verfasst: Montag 22. September 2008, 15:34
von nemomuk
leider auch nichts... (log-level: debug)
eine Frage: Wo muss genau diese Datei hin (fcgi):
Code: Alles auswählen
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home/user/python")
# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "pytest.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
wenn mein Projekt pytest heißt und in /var/www/pytest/ ist:
/var/www/pytest/__init__.py
/var/www/pytest/manage.py
...
Wo muss diese fcgi Datei hin, wenn ich im Apache das hier drin habe:
Alias / /var/www/python/pytest.fcgi/
Ich glaube hier liegt nämlich auch der Fehler...
Danke!
MfG
Verfasst: Montag 22. September 2008, 16:05
von Leonidas
In dem Fall muss die Datei nach ``/var/www/python/pytest.fcgi`` und für den Webserver sowohl les als auch ausführbar sein. Ich sehe, bei dir heißt die Datei falsch.