Dopo aver creato un'applicazione dJango. Basta seguire questi passi:
PASSO 1. Creare un file dire uwsgi.ini nella directory del progetto Django. Oltre a gestire.py
[uwsgi]
# set the http port
http = :<port_no>
# change to django project directory
chdir = <project directory>
# add /var/www to the pythonpath, in this way we can use the project.app format
pythonpath = /var/www
# set the project settings name
env = DJANGO_SETTINGS_MODULE=<project_name>.settings
# load django
module = django.core.handlers.wsgi:WSGIHandler()
FASE 2. Sotto /etc/nginx/sites-available aggiungere .conf file di
server {
listen 84;
server_name example.com;
access_log /var/log/nginx/sample_project.access.log;
error_log /var/log/nginx/sample_project.error.log;
# https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production
location /static/ { # STATIC_URL
alias /home/www/myhostname.com/static/; # STATIC_ROOT
expires 30d;
}
}
FASE 3. In nginx.conf, passare la richiesta alla tua applicazione Django
Sotto il blocco del server {},
location /yourapp {
include uwsgi_params;
uwsgi_pass <your app address, eg.localhost>:<portno>;
}
FASE 4. Eseguire il uwsgi.ini
> uwsgi --ini uwsgi.ini
Ora, qualsiasi richiesta al Nginx passerà la richiesta al Django App tramite uwsgi .. Enjoy :)
fonte
2012-09-22 06:19:17
di poter postare i tuoi file di configurazione? – j0nes
Quale sistema operativo server stai usando? I tre file importanti che dovremo vedere per aiutarti sono nginx.conf, il file abilitato al sito e la vassal config di uWSGI. – aychedee
Attualmente sto testando la distribuzione sul mio sistema (Ubuntu 12.04 LTS) –