django+;gunicorn&x2B;nginx在提供静态文件时提供404
django+gunicorn+nginx在提供静态文件时提供404 我正在尝试使用nginx+gunicorn+postgresql部署一个Django项目。所有的配置完成后,我的管理面板项目静态文件将服务,但其他静态文件;它返回404错误。(iam使用run python manage.py collectstatic)django+;gunicorn&x2B;nginx在提供静态文件时提供404,django,postgresql,docker,nginx,Django,Postgresql,Docker,Nginx,django+gunicorn+nginx在提供静态文件时提供404 我正在尝试使用nginx+gunicorn+postgresql部署一个Django项目。所有的配置完成后,我的管理面板项目静态文件将服务,但其他静态文件;它返回404错误。(iam使用run python manage.py collectstatic) 要通过collectstatic命令将/blogpy/home/static/文件复制到/blogpy/static/中,需要指定STATICFILES\u DIRS设置
要通过collectstatic命令将/blogpy/home/static/文件复制到/blogpy/static/中,需要指定STATICFILES\u DIRS设置
建议直接从
nginx
提供静态文件
将以下内容添加到nginx站点配置中
location /static/ {
alias /path/to/static/directory/;
}
试一试
在--nginx.conf中:
location /static/ {
autoindex off;
alias /home/ubuntu/blogpy/static/; #add full path of static file directry
}
location /static/ {
alias /path/to/static/directory/;
}
location /static/ {
autoindex off;
alias /home/ubuntu/blogpy/static/; #add full path of static file directry
}