Django-fr

Forum

#1 17-07-2012 08:29:46

Songohan
Membre
Lieu : Rhône (69)
Inscription : 24-05-2012
Messages : 6

[Résolu]Aide configuration django nginx uwgsi

Bonjour,

J'ai fait des développements en utilisant le serveur http intégré à django.
Je voudrais maintenant héberger mon appli sur un vrai serveur web, mais ça ne fonctionne pas.

Voici mes fichiers de configuration :

/etc/nginx/nginx.conf

server {
                listen       80;
                server_name  budget;

                #charset koi8-r;

                access_log  /var/log/nginx/budget/host.access.log  main;

                location / {
                        uwsgi_pass   unix:///var/run/uwsgi.sock;
                        include        uwsgi_params;

                }

                location /static{
                        alias  /var/development/django/budget/static;
                }
        }

Fichier de configuration /var/development/django/budget/django.ini :

[uwsgi]
socket  = /var/run/uwgsi.sock
chdir = /var/development/django/budget
module = wsgi:application
pidfile=/var/run/uwgsi.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/budget.log

Fichier de configuration /var/development/django/budget/wsgi.py

import os
import sys
import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()
os.environ['DJANGO_SETTINGS_MODULE'] = 'budget.settings'
sys.path.append('/var/development/django/budget')

Mon fichier de log :

*** Starting uWSGI 1.2.4 (32bit) on [Tue Jul 17 09:21:13 2012] ***
compiled with version: 4.7.1 on 14 July 2012 11:03:35
detected number of CPU cores: 2
current working directory: /var/development/django/budget
writing pidfile to /var/run/uwgsi.pid
detected binary path: /usr/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to UNIX address /var/run/uwgsi.sock fd 3
Python version: 2.7.3 (default, Apr 24 2012, 00:06:13)  [GCC 4.7.0 20120414 (prerelease)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x840b5d8
your server socket listen backlog is limited to 100 connections
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x840b5d8 pid: 6835 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 6835, cores: 1)

J'ai renseigné mon fichier hosts. nginx sert bien les fichiers statiques (css et images etc...), mais pas les pages dynamiques.
J'ai des erreurs 502 Bad Gateway.

Qu'est ce qui ne va pas dans ma configurantion ?

Edit :
Mon problème est résolu. nginx ne trouvait pas le socket.
J'ai remplacé :

socket  = /var/run/uwgsi.sock
pidfile=/var/run/uwgsi.pid

par :

socket  = /var/run/uwsgi.sock
pidfile=/var/run/uwsgi.pid

Dernière modification par Songohan (17-07-2012 09:04:32)

Hors ligne

#2 17-07-2012 09:18:06

ksamuel
Modérateur
Inscription : 22-06-2012
Messages : 40
Site Web

Re : [Résolu]Aide configuration django nginx uwgsi

C'est difficile de le savoir comme ça, mais la première chose que je
tenterai, c'est de rajouter :

sys.path.append('/var/development/django')

Au fichier wsgi.py et de bouger:

application = django.core.handlers.wsgi.WSGIHandler()

Tout en bas du fichier.

Le mar. 17 juil. 2012 09:29:46 CEST, Gabriel MACHADO a écrit :
> Bonjour,
>
> J'ai fait des développements en utilisant le serveur http intégré à
> django.
> Je voudrais maintenant héberger mon appli sur un vrai serveur web, mais
> ça ne fonctionne pas.
>
> Voici mes fichiers de configuration :
>
> /etc/nginx/nginx.conf
>

>  server {
>                 listen       80;
>                 server_name  budget;
>
>                 #charset koi8-r;
>
>                 access_log  /var/log/nginx/budget/host.access.log  main;
>
>                 location / {
>                         uwsgi_pass   unix:///var/run/uwsgi.sock;
>                         include        uwsgi_params;
>
>                 }
>
>                 location /static{
>                         alias  /var/development/django/budget/static;
>                 }
>         }
>

>
> Fichier de configuration /var/development/django/budget/django.ini :
>

> [uwsgi]
> socket  = /var/run/uwgsi.sock
> chdir = /var/development/django/budget
> module = wsgi:application
> pidfile=/var/run/uwgsi.pid
> vacuum=True
> max-requests=5000
> daemonize=/var/log/uwsgi/budget.log
>

>
> Fichier de configuration /var/development/django/budget/wsgi.py
>

> import os
> import sys
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
> os.environ['DJANGO_SETTINGS_MODULE'] = 'budget.settings'
> sys.path.append('/var/development/django/budget')
>

>
> Mon fichier de log :
>

> *** Starting uWSGI 1.2.4 (32bit) on [Tue Jul 17 09:21:13 2012] ***
> compiled with version: 4.7.1 on 14 July 2012 11:03:35
> detected number of CPU cores: 2
> current working directory: /var/development/django/budget
> writing pidfile to /var/run/uwgsi.pid
> detected binary path: /usr/bin/uwsgi
> uWSGI running as root, you can use --uid/--gid/--chroot options
> *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
> *** WARNING: you are running uWSGI without its master process manager ***
> your memory page size is 4096 bytes
> detected max file descriptor number: 1024
> lock engine: pthread robust mutexes
> uwsgi socket 0 bound to UNIX address /var/run/uwgsi.sock fd 3
> Python version: 2.7.3 (default, Apr 24 2012, 00:06:13)  [GCC 4.7.0
> 20120414 (prerelease)]
> *** Python threads support is disabled. You can enable it with
> --enable-threads ***
> Python main interpreter initialized at 0x840b5d8
> your server socket listen backlog is limited to 100 connections
> *** Operational MODE: single process ***
> WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x840b5d8
> pid: 6835 (default app)
> *** uWSGI is running in multiple interpreter mode ***
> spawned uWSGI worker 1 (and the only) (pid: 6835, cores: 1)
>

>
> J'ai renseigné mon fichier hosts. nginx sert bien les fichiers statiques
> (css et images etc...), mais pas les pages dynamiques.
> J'ai des erreurs 502 Bad Gateway.
>
> Qu'est ce qui ne va pas dans ma configurantion ?
> _______________________________________________
> django mailing list
> django _AT_ lists.afpy.org
> http://lists.afpy.org/mailman/listinfo/django

Hors ligne

Pied de page des forums