无法使Nginx与uWSGI一起使用

时间:2016-09-29 11:14:51

标签: python django nginx uwsgi centos6

我有一个名为test.py的测试文件:

def application(env, start_response):
        start_response('200 OK', [('Content-Type','text/html')])
        return [b"Hello World"]

我使用此命令运行uWSGI:

uwsgi --http :8001 --wsgi-file test.py

我可以通过转到xxxx.xxxx.xxxx.xxxx:8001

在浏览器中看到“Hello World”

现在我正在尝试添加Nginx。这是我的文件mysite_nginx.conf

# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    # server unix:///path/to/your/mysite/mysite.sock; # for a file socket
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8000 default_server;
    # the domain name it will serve for
    server_name _;

    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste





    location /static {
        alias /home/wz/dispatcher/OurAwesomeDjangoApp/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     /home/wz/dispatcher/OurAwesomeDjangoApp/uwsgi_params; # the uwsgi_params file you installed
    }
}

当我去xxxx.xxxx.xxxx.xxxx时,我看到了标准的“欢迎来到Nginx”。

但是,当我转到xxxx.xxxx.xxxx.xxxx:8000时,我无法连接。

Django服务器可以在这个端口python manage.py runserver 0.0.0.0:8000上工作。

uwsgi_params出现在我的项目目录中。

我还创建了/etc/nginx/sites-enabled

的符号链接

我缺少什么?任何帮助表示赞赏。

编辑:

当我使用yum install nginx安装nginx时,sites-available中没有sites-enabled/etc/nginx/个目录。

我手动创建了它们并添加了:

include /etc/nginx/sites-enabled/*;

/etc/nginx/nginx.conf

0 个答案:

没有答案