自己在linux下写了个django的demo,用python manage.py runserver运行时,
能够正确显示,当加上了nginx和gunicorn后,加载不了静态文件。
显示:NOT Found: /static/blog/css/bootstrap.min.css
nginx配置如下:
server {
charset utf-8;
listen 80;
server_name example.com;
location /static {
alias /home/chris/sites/blog_demo/static;
}
location / {
proxy_pass http://localhost:8080/;
}
}
测试nginx配置文件:
sudo nginx -t #test is successful
gunicorn 运行代码如下:
gunicorn -b localhost:8080 blogproject.wsgi:application
location里的路径和实际路径的结尾是相匹配的,建议用
root
指令以下配置应该也有效