uwsgi+nginx代理Django无法访问静态资源的解决

 

 


查看nginx启动用户,将静态资源赋权给改用户访问即可。
静态资源目录:/data/django/static
赋权:chmod 755 /data/django/static -R


settings.py
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]


STATIC_URL = '/static/'
# 设置开发时静态资源目录
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static_dev')
]
# 设置收集静态资源的路径(部署时使用)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

 

uwsgi.ini

#代理静态资源路径
static-map = /static=/home/ubuntu/projects/project/static
static-map = /static=/home/ubuntu/acollection/static

 



REF
https://www.jianshu.com/p/f23225d537b5

 

posted @ 2022-06-06 10:13  emanlee  阅读(236)  评论(0编辑  收藏  举报