尝试在Ubuntu 14.04上使用uwsgi和nginx设置django

尝试在Ubuntu 14.04上使用uwsgi和nginx设置django,django,nginx,Django,Nginx,简单明了,我似乎无法理解这一点。我应该能够进入mysite的媒体文件夹,并看到一个测试图像,但有点不对劲 这是我的conf文件: # catalog_nginx.conf # the upstream component nginx needs to connect to upstream django { #server unix:///home/ec2-user/catalog/catalog.sock; # for a file socket server 127.0.0

简单明了,我似乎无法理解这一点。我应该能够进入mysite的媒体文件夹,并看到一个测试图像,但有点不对劲

这是我的conf文件:

# catalog_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    #server unix:///home/ec2-user/catalog/catalog.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 54.xxx.xxx.xxx; # substitute your machine's IP address or FQDN -- xxx are numbers in the actual conf
    charset     utf-8;

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

    # Django media
    location /media  {
        alias /home/ec2-user/catalog/media;  # your Django project's media files - amend as required
    }

    location /static {

        alias /home/ec2-user/catalog/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/ec2-user/catalog/uwsgi_params; # the uwsgi_params file you installed
    }
}
当我转到54.xxx.xxx.xxx:8000/media/test.jpg时,我从页面上得不到爱

跟踪日志给了我以下信息:

2016/03/17 16:04:24[错误]13950#0:*2开放() “/usr/share/nginx/html/media/poweredby.png”失败(2:没有此类文件或 目录),客户端:66.xxx.xxx.xxx,服务器:localhost,请求:“GET” /media/poweredby.png HTTP/1.1“,主机:“54.xxx.xxx.xxx”,参考人: “”

Nginx知道在哪里查找我的站点\u Nginx.conf文件。。。我被难住了

帮忙

--更新--

文件夹“/usr/share/nginx/html/media/”不存在,但“/usr/share/nginx/html/”存在。。。“/static/”也是如此

sudo/etc/init.d/nginx configtest返回“ok”和“successful”

nginx.conf文件中是否有我可能丢失的内容

权限问题会导致这种行为吗?我应该如何检查,或者如何处理

--更新2--

不知何故,nginx被阻止在“/usr/share/nginx/html”中创建“/media”和“/static/”文件夹

我手动创建了文件夹,它提供了图像。我知道下一步该做什么

--哑更新--


先前问题中的ip地址已经更改,以防止乌克兰的男孩(或女孩)玩得太开心

看起来该请求可能没有命中nginx配置的这个片段。对
/media/poweredby.png
的请求应该发送到
/home/ec2 user/catalog/media/poweredby.png
,而不是默认的nginx位置
/usr/share/nginx/html/media/poweredby.png
。是否可能您的根nginx.conf中没有包含此特定配置文件

看起来是这样的:

# nginx.conf

user nginx; 

http { 

# stuff would go here 

}

include /etc/nginx/catalog_nginx.conf;

您的服务器名称正确吗?可能请求与您的服务器块不匹配。看起来像是uWSGI站点的教程,我已经看过了。尝试:1)删除
站点启用
目录中的
默认
配置。2) 停止并重新启动
nginx
(?)。