【发布时间】:2019-03-09 00:27:22
【问题描述】:
重新启动后,我的 Django-Nginx 设置神秘地停止向我的站点提供静态文件。该网站似乎可以正常托管,但当我的网站尝试提供 CSS 文件和其他静态内容时,我收到了“404”错误。
“CoolBlog”是项目名称,“Blog”是应用程序名称。
目录树:
site.mywebsite.com
|
├── database
│ └── db.sqlite3
├── source
│ ├── blog
│ ├── CoolBlog
│ ├── functional_tests.py
│ ├── manage.py
│ ├── requirements.txt
│ └── static
├── static
│ ├── admin
│ ├── bootstrap-4.3.1-dist
│ ├── css
│ └── styles.css
└── virtualenv
├── bin
└── lib
CoolBlog/settings.py 中的相关部分:
STATIC_ROOT = os.path.join(BASE_DIR, '../static')
STATIC_URL = '/static/'
站点可用/site.mywebsite.com:
server{
listen 80;
server_name site.mywebsite.com;
location /source/static {
alias /home/elspeth/sites/site.mywebsite.com/static;
autoindex on;
}
location / {
proxy_pass http://unix:/tmp/site.mywebsite.com.socket;
proxy_set_header Host $host;
}
}
软件/操作系统版本:
Ubuntu 16.04.6 LTS
Django 2.1.7
nginx/1.10.3
独角兽 19
非常感谢有关如何进行的建议。
【问题讨论】:
-
只是确认一下,Debug 是否设置为 False?
-
是的。调试设置为 False。