Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
django+;gunicorn&x2B;nginx在提供静态文件时提供404_Django_Postgresql_Docker_Nginx - Fatal编程技术网

django+;gunicorn&x2B;nginx在提供静态文件时提供404

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设置

django+gunicorn+nginx在提供静态文件时提供404

我正在尝试使用nginx+gunicorn+postgresql部署一个Django项目。所有的配置完成后,我的管理面板项目静态文件将服务,但其他静态文件;它返回404错误。(iam使用run python manage.py collectstatic)


要通过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
}