1. django版本4.2.1
2. uwsgi 版本2.0.21
3. uwsgi配置文件
[uwsgi]
chdir = /home/djangoProject
wsgi-file = djangoProject/wsgi.py
master = true
processes = 4
threads = 2
http = 0.0.0.0:50672
daemonize = %(chdir)/uwsgi.log
disable-logging = true
static-map = /static=collectedstatic
vacuum = true
pidfile = %(chdir)/uwsgi.pid
# 备注: http访问使用http, 如果需要配合nginx使用, 请吧http修改为socket
4. 使用虚拟环境pypoetry
5. 收集静态文件
5.1 django项目settings.py配置
STATIC_URL = "static/"
STATIC_ROOT = os.path.join(BASE_DIR, "collectedstatic")
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"),]
5.2 收集静态文件
/home/.cache/pypoetry/virtualenvs/djangoproject-Zu7Z7svv-py3.11/bin/python3.11 manage.py collectstatic
6. 启动uwsgi
cd /home/djangoProject
/home/.cache/pypoetry/virtualenvs/djangoproject-Zu7Z7svv-py3.11/bin/uwsgi --ini uwsgi.ini