一、将远程git仓库中的项目拉取到服务器中的git仓库
1.新建ihome文件夹
mkdir ihome
2.新建仓库
cd ihome
git init
3.本地仓库与远程仓库进行配对
git remote add origin git@github.com:iamluyunhao/ihome.git
4.本地仓库新建分支
git checkout -b test
5.将远程仓库内容拉取到本地仓库
git pull origin master
二、测试环境中部署Flask项目
1.创建虚拟环境
virtualenv --no-site-packages -p /usr/local/python3/bin/python3 ajenv
2.安装环境所需要的包
/home/env/ajenv/bin/pip install -r requiredment.txt
3.修改setting.py配置文件
REDIS_DATABASE = {
'HOST': '127.0.0.1',
'PASSWORD': '123456',
'PORT': '6379'
}
4.修改config.py配置文件
SESSION_REDIS = redis.Redis(host=REDIS_DATABASE['HOST'], password=REDIS_DATABASE['PASSWORD'], port=REDIS_DATABASE['PORT'])
5.启动Flask项目
/home/env/ajenv/bin/python3 /home/src/ihome/manage.py runserver -p 82 -h 0.0.0.0
三、服务器中正式部署Flask项目
1.安装uwsgi
/home/env/ajenv/bin/pip3 install uwsgi
2.配置nginx.conf文件
注意:manage:项目中的应用名
server {
listen 82;
server_name www.jackhao.top;
access_log /home/logs/aj_access.log;
error_log /home/logs/aj_error.log;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
uwsgi_param UWSGI_CHDIR /home/src/ihome;
uwsgi_param UWSGI_SCRIPT manage:app;
}
}
3.配置uwsgi.ini文件
注意:callable =项目中的应用名
[uwsgi]
master = true
socket = 127.0.0.1:9090
chdir = /home/src/ihome
pythonpath = /home/env/ajenv/bin/python3
callable = app
logto = /home/logs/aj_uwsig.log
4.重启nginx服务
systemctl restart nginx
systemctl status nginx
5.配置启动启动文件
touch start_aj.sh
vim start_aj.sh
/home/env/ajenv/bin/uwsgi --ini /home/conf/aj_uwsgi.ini
6.启动项目
nohup ./start_aj.sh &
网友评论