Ich versuche, die Schritte in diesem Handbuch zu befolgen: http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Bevor ich überhaupt zum Nginx-Teil komme, versuche ich sicherzustellen, dass uWSGI korrekt funktioniert
meine Ordnerstruktur ist srv/www/domain/projectdatabank /
der Projektdatenbankordner enthält meine Datei manage.py
meine wsgi.py-Datei sieht folgendermaßen aus:
import os
import sys
from Django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
müssen Sie meine settings.py sehen?
ich erhalte die folgende Fehlermeldung, wenn ich auf den Browser zeige:
-- no python application found, check your startup logs for errors --- [pid: 10165|app: -1|req: -1/1] 66.56.35.151 () {38 vars in 681 bytes} [Tue Jul 9 18:19:46 2013] GET /admin/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 1 headers in 57 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 10165|app: -1|req: -1/2] 66.56.35.151 () {36 vars in 638 bytes} [Tue Jul 9 18:19:49 2013] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 1 headers in 57 bytes (0 switches on core 0)
Wenn ich jetzt mein UWGI-Protokoll überprüfe, ist es genau das gleiche wie oben.
Ich habe das gelöst
in meiner ursprünglichen Befehlszeile war der vollständige Pfad zur Datei wsgi.py zum Ausführen von uWSGI nicht angegeben
uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file wsgi.py
dazu
uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file full/path/wsgi.py
und es hat funktioniert
Für andere, die denselben Fehler debuggen, gibt es eine andere Möglichkeit: Eine Ausnahme wird von Ihrem uwsgi.py
. Um dies zu testen, öffne eine Django Shell in deiner App direkt mit python manage.py Shell
und importiere dein uwsgi.py
(benutze den gleichen Pfad wie in deinem uwsgi.ini
).
Lesen Sie meinen Blogbeitrag zum Deployment von Django= behind uwsgi http://blog.johannesklug.de/2012/11/27/deploying-Django-behind-nginx-with-uwsgi -and-virtualenv / . Ich habe eine ini-Datei zum Einrichten von uwsgi erstellt, die auf die mit dem Parameter module=project.wsgi:application
aufrufbare App verweist.
Die ganze Datei sieht ungefähr so aus:
(env)[[email protected] ~]$ cat uwsgi.ini
[uwsgi]
# path to where you put your project code
chdir=/home/project/project
# python path to the wsgi module, check if you have one
module=project.wsgi:application
# this switch tells uwsgi to spawn a master process,
# that will dynamically spawn new child processes for
# server requests
master=True
# uwsgi stores the pid of your master process here
pidfile=/home/project/master.pid
vacuum=True
# path to your virtual environment
home=/home/project/env/
# path to log file
daemonize=/home/project/log
# this is where you need to point nginx to,
# if you chose to put this in project home make
# sure the home dir is readable and executable by
# nginx
socket=/tmp/uwsgi.sock
### SEE UPDATE NOTICE FOR THIS ONE
env = Django_SETTINGS_MODULE=project.settings
Bitte beachte, dass ich virtualenv verwende.
Möglicherweise fehlen Ihnen auch die Zeilen
import os
os.environ.setdefault("Django_SETTINGS_MODULE", "project.settings")
in deiner wsgi.py
Überprüfen Sie, ob Sie eine init .py-Datei aus den Djano-Apps gelöscht haben. Da Django verwendet, um zu wissen, welche Ordner Apps sind, sind sie irgendwie wichtig.