Internal server error with Django and uWSGI

I am trying to follow these steps in this guide: http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Before I get to the nginx part, I try to make sure uWSGI is working correctly

my folder structure is srv / www / domain / projectdatabank /

the project database folder contains the manage.py file

My wsgi.py file looks like this:

import os import sys from django.core.wsgi import get_wsgi_application application = get_wsgi_application() 

Do you need to see my settings.py?

I get the following error when I point myself to the browser:

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

Now when I check my uWGI log, it is the same as above.

+41
source share
4 answers

I decided it

in my original command line the full path to the wsgi.py file was not included to start uWSGI

 uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file wsgi.py 

to that

 uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file full/path/wsgi.py 

and he worked

+45
source

For others debugging the same error, there is another possibility: an exception is thrown by your uwsgi.py . To verify this, open the django shell in the application directly using the python manage.py shell and import uwsgi.py (use the same path as in uwsgi.ini ).

+42
source

Post a blog post about deploying Django for uwsgi http://blog.johannesklug.de/2012/11/27/deploying-django-behind-nginx-with-uwsgi-and-virtualenv/ . I created an ini-File to configure uwsgi, which points to the application called with the module=project.wsgi:application parameter.

The whole file reads something like this:

 (env)[ project@host ~]$ 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 

Please note that I am using virtualenv.

You may also be missing lines

 import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") 

in wsgi.py

+12
source

Check if you have deleted the init .py file from Djano applications. Since django uses them to know which folders are applications, they are very important.

0
source

Source: https://habr.com/ru/post/970658/


All Articles