无法使用uwsgi + Django连接Nginx

时间:2017-11-07 01:42:07

标签: django nginx uwsgi

我尝试过的: 1. Nginx很好,可以访问80端口并查看默认页面 2. uwsgi + django很好,我可以使用uwsgi启动我的django应用程序并访问它 ,用命令:

uwsgi --http :8000 --module webapps.wsgi

当我将uwsgi连接到nginx

时出现问题
2017/11/07 01:36:47 [error] 27958#27958: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 71.61.176.181, server: 104.196.31.159, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "104.196.31.159:8000"

这是nginx的mysite.conf

# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    #server unix:///home/liuziqicmu/ziqil1/homework/6/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;
    # the domain name it will serve for
    server_name xx.xx.xx.xx(my ip); # substitute your machine's IP address or FQDN
    charset     utf-8;

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

    # Django media
    location /media  {
        alias /home/liuziqicmu/ziqil1/homework6/grumblr/upload;  # your Django project's media files - amend as required
    }

    location /static {
        alias /home/liuziqicmu/ziqil1/homework6/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/liuziqicmu/ziqil1/homework/6/env/uwsgi_params; # the uwsgi_params file you installed
    }
}

我启动它的命令:

uwsgi --socket 8001 --module webapps.wsgi

另外,当我运行nginx -t时,它会显示:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2017/11/07 02:02:13 [warn] 19350#19350: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2017/11/07 02:02:13 [emerg] 19350#19350: open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed

这会有问题吗?

1 个答案:

答案 0 :(得分:0)

确保/var/log/nginx/run存在并且可以由nginx

编写
相关问题