我正在尝试提供 Django 管理静态文件,但似乎没有任何效果,下面是我的 nginx 配置:
upstream django {
server 127.0.0.1:8000;
}
server {
listen 4321;
server_name localhost;
charset utf-8;
access_log /var/log/nginx/local-access.log;
error_log /var/log/nginx/local-error.log;
client_max_body_size 75M;
include /etc/nginx/mime.types;
location /static/ {
alias /home/vaibhav/TRAC/bright-coupons/brightCoupons/brightCouponsApp/static/;
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}
}
我不明白我的模板工作正常但 Django 管理面板不行...我已经使用了 python manage.py collectstatic 命令现在所有 Django 静态文件都在我的应用程序的静态文件夹中。
Nginx 访问日志:
127.0.0.1 - - [14/May/2013:16:44:24 +0530] "GET /bcadmin/brightCouponsApp/static/admin/css/base.css HTTP/1.1" 500 5 "http://localhost:4321/bcadmin/" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31"
uWSGI日志:
[pid: 10689|app: 0|req: 1/3] 127.0.0.1 () {46 vars in 895 bytes} [Tue May 14 16:44:24 2013] GET /bcadmin/brightCouponsApp/static/admin/css/login.css => generated 0 bytes in 30522 msecs (HTTP/1.1 500)
nginx 错误日志是空的......
答案1
您需要设置根:
root /home/vaibhav/TRAC/bright-coupons/brightCoupons/brightCouponsApp;
或者设置位置以匹配 uri 中的任何 /static/:
location ~* ^/static/*$ {