E
E
evve2015-10-12 19:47:42
Django
evve, 2015-10-12 19:47:42

How to setup wsgi + gunicorn + nginx + django?

I'm building a website on the server.
The sitename/sitename/wsgi.py folder contains the standard code:

import os
from django.core.handlers.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sitename.settings")
application = get_wsgi_application()

The django 1.8 instructions say to run with gunicorn you need to do this: gunicorn sitename.wsgi
Where does the sitename.wsgi file come from? I didn't have it initially. And if it needs to be created, as I understand it, the settings (paths to) of the project should be?
import os, sys
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'sitename.settings'
application = django.core.handlers.wsgi.WSGIHandler()

I put the file in the same place as wsgi.py I
run gunicorn sitename.wsgi I get an
error:
ImportError: No module named sitename.wsgi
Please explain how to run this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
evve, 2015-10-15
@evve

I was looking for the query "nginx uwsgi django" and found a really working instruction blog.djangofan.ru/2014/01/django-uwsgi-nginx-ubunt ...

R
Roman Kitaev, 2015-10-12
@deliro

Right here

V
Vlad T., 2015-10-17
@est

Where is the sitename.wsgi file from? I didn't have it initially.

I mean python path, i.e. wsgy.py file in the /sitename/ folder , for example /sitename/wsgi.py
Accordingly, the command gunicorn sitename.wsgimust be run from the project folder where /sitename/ is located

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question