django 部署

django部署

静态文件归集

在setting中配置

#静态文件聚合目录
STATIC_ROOT = os.path.join(BASE_DIR, 'collect_static')
执行命令
python manage.py collectstatic

uwsgi

#安装
pip install uwsgi 
#创建软连接
ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi

  

配置文件uwsgi.ini

[uwsgi]
master = true
processes = 1
threads = 2
chdir = /www/wwwroot/CRM/
http = 0.0.0.0:8001
logto = /www/wwwroot/CRM//logs/error.log
chmod-socket = 660
vacuum = true
master = true
max-requests = 1000

操作

uwsgi --ini uwsgi.ini             # 启动
uwsgi --reload uwsgi.pid          # 重启
uwsgi --stop uwsgi.pid            # 关闭

部署步骤
1.归集静态文件
#静态文件聚合目录
STATIC_ROOT = os.path.join(BASE_DIR, 'collect_static')
执行命令
python manage.py collectstatic
2.在setting配置允许访问
ALLOWED_HOSTS = ['*']
3.导出所有扩展包
#在虚拟环境中执行
pip freeze >requirements.txt
4.上传到服务器
使用git
5.配置websocket

6.配置http以及静态资源访问
nginx配置
#静态资源     
   location /static/
{
    alias /www/wwwroot/dnp/collect_static/;
}
7.释放阿里云端口,以及其他必要端口,例如面板
8.对版本限制报错,采取升级或者注释环境报错

参考 宝塔部署
原文地址:https://www.cnblogs.com/huay/p/11686383.html