使用Django和Uwsgi进行部署 [英] Deployment with Django and Uwsgi
问题描述
我的问题是uwsgi没有处理Django项目的静态文件.我是Web开发领域的新手,我正在本教程中进行uswgi部署( https://uwsgi.readthedocs.io/en/latest/tutorials/Django_and_nginx.html )当uwsgi运行django时,我停留在舞台上.我原本希望uwsgi在运行后会处理静态文件:
My problem is that uwsgi doesn't server static files of the django project. I am very new in web development and I was following this tutorial with uswgi deployment (https://uwsgi.readthedocs.io/en/latest/tutorials/Django_and_nginx.html) I stuck on the stage when uwsgi run django. I was expecting that uwsgi will server static files after I ran:
python manage.py collectstatic
然后
uwsgi --http:8000 --module myproject.wsgi
但是当我上127.0.0.1:8000时,我会看到类似这样的内容在此处输入图片描述
But when I get on 127.0.0.1:8000 I see something like this enter image description here
项目结构微不足道
--myproject:
-----myproject:
-------myproject:
----------init.py
----------settings.py
----------urls.py
----------wsgi.py
-------static
-------manage.py
-------db.sqlite3
-----venv
谢谢您的提示或帮助.
推荐答案
仅使用uwsgi进行此操作的最简单方法是添加 static-map
参数,即-static-map =/static =/path/to/my/proj/ect/static
.
The easiest way to do this with uwsgi alone is to add the static-map
parameter, i.e. --static-map=/static=/path/to/my/proj/ect/static
.
(如果您要使用 MEDIA_ROOT
,也要这样做.)
(You'll want to do this for your MEDIA_ROOT
too if you use it.)
这篇关于使用Django和Uwsgi进行部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!