部署流程
安装虚拟环境
pip2 install virtualenvwrapper
# **查找安装路径**
which virtualenvwrapper.sh

安装git用来传代码
Uwsgi
Nginx
最后更新于
pip2 install virtualenvwrapper
# **查找安装路径**
which virtualenvwrapper.sh

最后更新于
vim ~/.bashrc
# 增加以下环境变量
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.shsource .bashrcwhich python3mkvirtualenv --python=/usr/bin/python3 name-env
workon name-envworkon name-evn
cd ~/.virtualenvs/name-env/bin/deactivate name-envyum install git# 生成公钥
ssh-keygen -t rsa -C “email”
# 查看公钥
cat ~/.ssh/id_rsa.pub
#同步代码
git clone pip3 install uwsgi [uwsgi]
# 必须全部为绝对路径
# 项目的路径
chdir = /root/flask_f/
# Django的wsgi文件
wsgi-file = /root/flask_f/app.py
# 回调的app对象
callable = app
# Python虚拟环境的路径
home = /root/.virtualenvs/small-env
# 进程相关的设置
# 主进程
master = true
# 最大数量的工作进程
processes = 10
# nginx 直接用socket
#http = :80
socket = /root/flask_f/small.sock
# 设置socket的权限
chmod-socket = 666
# 退出的时候是否清理环境
vacuum = trueuwsgi --ini uwsgi.inicd /etc/nginx/conf.dupstream small{
server unix:///root/flask_f/small.sock;
}
# 配置服务器
server {
# 监听的端口号
listen 80;
# 域名
server_name 47.111.249.148;
charset utf-8;
# 最大的文件上传尺寸
client_max_body_size 75M;
# 静态文件访问的url
location /static {
# 静态文件地址
alias /root/flask_f/static;
}
# 最后,发送所有非静态文件请求到django服务器
location / {
uwsgi_pass small;
# uwsgi_params文件地址
include /etc/nginx/uwsgi_params;
}
}