简单明了,我似乎无法弄清楚这一点。我应该能够访问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 open() “/usr/share/nginx/html/media/poweredby.png”失败(2:没有这样的文件或 目录),客户端:66.xxx.xxx.xxx,server:localhost,request:“GET /media/poweredby.png HTTP / 1.1“,主机:”54.xxx.xxx.xxx“,推荐人: “http://54.xxx.xxx.xxx/media/”
Nginx知道在哪里查找我的site_nginx.conf文件......我很难过。
帮助?
- UPDATE -
文件夹'/ usr / share / nginx / html / media /'不存在,但'/ usr / share / nginx / html /'确实......同样适用于'/ static /'
sudo /etc/init.d/nginx configtest返回'ok'和'success'
nginx.conf文件中是否有任何我可能遗漏的内容?
许可问题会导致这种行为吗?我应该如何检查或解决这个问题?
- 更新2 -
不知何故,nginx被阻止在'/ usr / share / nginx / html'中创建'/ media'和'/ static /'文件夹
我手动创建了文件夹并提供了图片。我知道下一步该做什么。
- 哑更新 -
之前问题中的IP地址已被更改,以防止乌克兰的男人(或女孩)有太多的乐趣。
答案 0 :(得分:0)
看起来这个请求可能没有达到这个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;