参考:
https://zhuanlan.zhihu.com/p/31475023
#settings.py
DEBUG = False
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_FINDERS=(
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder"
)
#收集静态文件,把以前放在app下static中的静态文件全部拷贝到 settings.py 中设置的 STATIC_ROOT 文件夹中
python manage.py collectstatic
#在urls.py添加静态文件路由
if not settings.DEBUG:
urlpatterns += [url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT})]
#安装gunicorn
pip3 install gunicorn
/usr/local/python3/bin/gunicorn -w4 -b0.0.0.0:8001 --chdir /path_to/you_project your_project.wsgi