Anu*_*815 10 css python django gunicorn django-deployment
我正在尝试用gunicorn和nginx部署我的django项目,但我需要一些帮助.当我编码gunicorn myproject.wsgi:应用程序我设法在localhost页面看到我的网站,但没有任何CSS.为什么gunicorn不加载我的项目的静态文件夹中的css文件?
Guinicorn_start脚本:https ://dpaste.de/TAc4 Gunicorn 输出:https://dpaste.de/C6YX
小智 14
Gunicorn只会提供动态内容,即Django文件.因此,您需要设置代理服务器(如nginx)来处理静态内容(您的CSS文件).我假设你正在以正确的方式启动Gunicorn,所以你只需要配置nginx来提供静态文件.您可以使用以下配置,只需更改静态文件的路径:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_pass http://127.0.0.1:8000;
}
location /static {
autoindex on;
alias /path/to/staticfiles;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Run Code Online (Sandbox Code Playgroud)
即使设置了此配置,也必须调用"./manage.py collectstatic"来使css正常工作
| 归档时间: |
|
| 查看次数: |
11459 次 |
| 最近记录: |