Python NGINX/Django:403提供静态文件时出错
我花了很多很多时间调试这个,但还没有找到解决方案。我尝试过应用十几个相关线程的解决方案,但都没有解决问题(或者我实现了错误的解决方案) 我正在尝试使用nginx和django为媒体和静态文件提供服务,并且正在使用一个媒体文件进行测试(如下)。日志显示它正在尝试获取正确的文件,但它只是没有这样做的权限(Python NGINX/Django:403提供静态文件时出错,python,django,nginx,Python,Django,Nginx,我花了很多很多时间调试这个,但还没有找到解决方案。我尝试过应用十几个相关线程的解决方案,但都没有解决问题(或者我实现了错误的解决方案) 我正在尝试使用nginx和django为媒体和静态文件提供服务,并且正在使用一个媒体文件进行测试(如下)。日志显示它正在尝试获取正确的文件,但它只是没有这样做的权限(失败(13:权限被拒绝))。一切都设置为755。我的nginx.conf和mysite_nginx.conf如下所示。有什么想法吗 nginx.conf worker_processes 1; e
失败(13:权限被拒绝)
)。一切都设置为755。我的nginx.conf和mysite_nginx.conf如下所示。有什么想法吗
nginx.conf
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/etc/nginx/logs/access.log main;
sendfile on;
keepalive_timeout 65;
index index.html index.php;
include /usr/local/etc/nginx/sites-enabled/mysite_nginx.conf;
}
upstream django {
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
listen 8000;
server_name localhost;
root /var/www/;
access_log /usr/local/etc/nginx/logs/default.access.log main;
location / { } #go to default index.html
location /media/ {
alias /Users/meep_me/Desktop/ram_stuff/combining/box/mysite/media/; # your Django project's media files
}
location /static/ {
alias /Users/meep_me/Desktop/ram_stuff/combining/box/mysite/static/; # your Django project's static files
}
location /other {
uwsgi_pass django;
include /Users/meep_me/Desktop/ram_stuff/combining/box/mysite/uwsgi_params; # the uwsgi_params file you installed
}
}
mysite_nginx.conf
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/etc/nginx/logs/access.log main;
sendfile on;
keepalive_timeout 65;
index index.html index.php;
include /usr/local/etc/nginx/sites-enabled/mysite_nginx.conf;
}
upstream django {
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
listen 8000;
server_name localhost;
root /var/www/;
access_log /usr/local/etc/nginx/logs/default.access.log main;
location / { } #go to default index.html
location /media/ {
alias /Users/meep_me/Desktop/ram_stuff/combining/box/mysite/media/; # your Django project's media files
}
location /static/ {
alias /Users/meep_me/Desktop/ram_stuff/combining/box/mysite/static/; # your Django project's static files
}
location /other {
uwsgi_pass django;
include /Users/meep_me/Desktop/ram_stuff/combining/box/mysite/uwsgi_params; # the uwsgi_params file you installed
}
}
正如warath coder在评论中提到的那样。我忘了明确地确保每个文件夹都设置了+x位。仔细检查并找到没有解决问题的那个 正如warath coder在评论中提到的那样。我忘了明确地确保每个文件夹都设置了+x位。仔细检查并找到没有解决问题的那个
/Users/meep_me/Desktop/ram_stuff/combing/box/mysite/media/
:每个文件夹是否都设置了权限的+x
位(通常需要列出/访问文件夹/子文件夹)?/Users/meep\u me/Desktop/ram\u stuff/combing/box/mysite/media/
:每个文件夹是否设置了+x
位权限(通常需要列出/访问文件夹/子文件夹)?/Users/meep\me/Desktop/ram\u stuff/combing/box/mysite/media/每个文件夹是否设置了+x位权限(通常需要列出/访问折叠/子文件夹)噢,哇。我原以为所有内容都包括在内,但结果只是/Desktop没有设置。谢谢!/Users/meep_me/Desktop/ram_stuff/combing/box/mysite/media/
每个文件夹是否都设置了+x位权限(通常需要列出/访问折叠/子文件夹)哦,哇。我原以为一切都准备好了,但结果只是/桌面没有设置。谢谢!