一馍悟、將遠程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.將遠程倉庫內(nèi)容拉取到本地倉庫
git pull origin master
二赃承、測試環(huán)境中部署Flask項目
1.創(chuàng)建虛擬環(huán)境
virtualenv --no-site-packages -p /usr/local/python3/bin/python3 ajenv
2.安裝環(huán)境所需要的包
/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 &