与uwsgi和django连接的NGINX被拒绝

时间:2015-02-27 10:54:53

标签: django nginx wsgi uwsgi

欢迎stackoverflowers。我一直在与使用django应用程序的uwsgi设置nginx ...在某处有一个小错误,但我找不到它。这是来自pastebin的文件,包含与我的问题直接相关的文件以及控制台日志。如果有人可以看看并帮助我,我会非常有帮助。

artcolor_uwsgi.ini文件

[uwsgi]

chdir           = /home/seb/pypassion/artcolor/src/
module          = artcolor.wsgi
home            = /home/seb/pypassion/artcolor/artcolor_venv/

master          = true
processes       = 10
socket          = /home/seb/pypassion/artcolor/src/artcolor.sock
#http-socket = :8001

#vacuum          = true

artcolor_nginx.conf文件

upstream django {
    server /home/seb/pypassion/artcolor/src/artcolor.sock; # for a file socket
    #server 127.0.0.1:8001;
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8001;
    server_name localhost; # substitute your machine's IP address or FQDN
    charset     utf-8;

    access_log /home/seb/pypassion/artcolor/logs/nginx-access.log;
    error_log /home/seb/pypassion/artcolor/logs/nginx-error.log;


    # max upload size
    client_max_body_size 1G;   # adjust to taste

    # Django media
    location /media/  {
        alias /home/seb/pypassion/artcolor/src/media/;  # your Django project's media files - amend as required
    }

    location /static/ {
        alias /home/seb/pypassion/artcolor/src/static/; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include    uwsgi_params; # the uwsgi_params file you installed
    }
}

wsgi.py文件

import os
import sys

sys.path.append("/home/seb/pypassion/artcolor/src/")
sys.path.append("/home/seb/pypassion/artcolor/src/artcolor/")

sys.path = sys.path[::-1]

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "artcolor.settings")

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

我的控制台

(artcolor_venv)seb@debian:~/pypassion/artcolor/src$ uwsgi --ini artcolor_uwsgi.ini
[uWSGI] getting INI configuration from artcolor_uwsgi.ini
*** Starting uWSGI 2.0.9 (64bit) on [Fri Feb 27 11:48:45 2015] ***
compiled with version: 4.7.2 on 27 February 2015 11:00:34
os: Linux-3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u2
nodename: debian
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /home/seb/pypassion/artcolor/src
detected binary path: /home/seb/pypassion/artcolor/artcolor_venv/bin/uwsgi
chdir() to /home/seb/pypassion/artcolor/src/
your processes number limit is 63796
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /home/seb/pypassion/artcolor/src/artcolor.sock fd 3
Python version: 2.7.3 (default, Mar 13 2014, 11:26:58)  [GCC 4.7.2]
Set PythonHome to /home/seb/pypassion/artcolor/artcolor_venv/
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x20e9d30
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 800448 bytes (781 KB) for 10 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x20e9d30 pid: 14848 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 14848)
spawned uWSGI worker 1 (pid: 14849, cores: 1)
spawned uWSGI worker 2 (pid: 14850, cores: 1)
spawned uWSGI worker 3 (pid: 14851, cores: 1)
spawned uWSGI worker 4 (pid: 14852, cores: 1)
spawned uWSGI worker 5 (pid: 14853, cores: 1)
spawned uWSGI worker 6 (pid: 14854, cores: 1)
spawned uWSGI worker 7 (pid: 14855, cores: 1)
spawned uWSGI worker 8 (pid: 14856, cores: 1)
spawned uWSGI worker 9 (pid: 14857, cores: 1)
spawned uWSGI worker 10 (pid: 14858, cores: 1)

解决 我将我的nginx文件链接到了网站 - 不是因为我被置于已启用网站

1 个答案:

答案 0 :(得分:0)

解决方案:

我设法解决了问题。

链接nginx.conf文件的原因是错误的。

我意外地链接到sites-available,而不是我应该sites-enabled

由于