Maybe even better than uwsgi, assume the django project in PRJ_NAME
pip install gunicorn
cd PRJ_NAME
gunicorn -w 2 PRJ_NAME.wsgi:application --bind 0.0.0.0:8000
try more
#!/bin/bash
# 项目的目录
DJANGODIR=/Users/workspace/hello_django/
# 应用名称
PRJNAME='PRJ_NAME'
# USER=root # --user=$USER --group=$GROUP \
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=$PRJNAME.settings
DJANGO_WSGI_MODULE=$PRJNAME.wsgi
LOG_DIR=$DJANGODIR/deploy
# 激活Python运行环境
cd $DJANGODIR
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# 启动Django
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $PRJNAME \
--workers $NUM_WORKERS \
--log-level=debug \
--bind='127.0.0.1:8000' \
--access-logfile=${LOG_DIR}/gunicorn_access.log
execute
nohup ./deploy/gunicorn.sh >./deploy/gunicorn.out 2>&1 &
nginx
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
check
open http://localhost
Done
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。