nginx + django无法加载静态static文件夹内容(css,js等)

nginx + django无法加载静态static文件夹内容

遇到一个问题,使用nginx + django 配置时,static文件夹无法加载(css,js,等)
经测试使用ip访问网页的时候一切正常,但是使用网址访问时,static内的文件都无法加载

查看浏览器报错,发现服务器竟然回复了“404”!
Failed to load resource: the server responded with a status of 404 ()
在这里插入图片描述
结合网上的说法,可以确定是权限问题,导致无法访问static文件夹的内容

方法:

修改 nginx.conf 的第一行
因为我的文件是在/root/下的
所以将 user nginx; 改为 user root;
重新加载nginx配置后即可顺利加载static

猜你喜欢

转载自blog.csdn.net/weixin_45760685/article/details/105211933
今日推荐