【发布时间】:2015-10-08 19:21:08
【问题描述】:
我对此有点陌生,但我正在尝试使用 nginx/gunicorn 将我使用 Django 构建的网站部署到 DigitalOcean。
我的 nginx 文件如下所示:
server {
listen 80;
server_name xxx.xxx.xxx.xx;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
alias ~/dev/WebPortfolio/static/;
}
}
我的 settings.py 文件如下所示:
STATIC_ROOT = '~/dev/WebPortfolio/static/'
STATIC_URL = '/static/'
STATICFILES_DIRS = ()
每次我运行 python managy.py collect static 时,错误都会如下所示:
You have requested to collect static files at the destination
location as specified in your settings:
/root/dev/WebPortfolio/~/dev/WebPortfolio/static
查看我看到的nginx错误日志(删掉重复的东西):
2015/10/08 15:12:42 [error] 23072#0: *19 open() "/usr/share/nginx/~/dev/WebPortfolio/static/http:/cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.e asing.min.js" failed (2: No such file or directory), client: xxxxxxxxxxxxxx, server: xxxxxxxxxxxxxx, request: "GET /static/http%3A//cdnjs.cloudflare.com/aj ax/libs/jquery-easing/1.3/jquery.easing.min.js HTTP/1.1", host: "XXXXXXXX.com", referrer: "http://XXXXXXXX.com/"
2015/10/08 15:14:28 [error] 23072#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: xxxxxxxx, server: 104.236.174.46, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "xxxxxxxx.com"
1) 我不完全确定为什么我的静态文件目的地是 '/root/dev/WebPortfolio/~/dev/WebPortfolio/static'
【问题讨论】:
-
除了丹尼尔给出的答案之外,我相信你在这里缺少一个斜杠“http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/j”