1.申請雲主機python
a.阿里雲 (注意:阿里雲的服務器須要手動添加安全規則使能80端口)mysql
b.騰訊雲nginx
2.把網站服務器程序拷貝到雲主機sql
3.遠程登陸雲主機數據庫
4.解壓網站服務器程序vim
yum install bzip2安全
tar -xvf 03IotServer.tar.bz2服務器
5.安裝Python3app
yum list |grep python網站
yum install python36.x86_64
6.建立Python虛擬環境
cd 03IotServer
mkdir env
python36 -m venv ./env/
7.安裝網站服務器須要的包
./env/bin/pip install --upgrade pip
./env/bin/pip install -r requirements.txt
8.安裝mysql
yum list |grep maridb
yum install mariadb.x86_64 mariadb-server.x86_64
systemctl restart mariadb
mysql_secure_installation
9.建立數據庫
mysql -uroot -pLzy123456
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS uplooking DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
10.修改網站服務器配置
vim config.py
修改mysql用戶名、密碼、數據庫
11.數據庫遷移
./env/bin/python run.py db init
./env/bin/python run.py db migrate
./env/bin/python run.py db upgrade
12.調用網站服務器的init命令
./env/bin/python run.py init
13.安裝gunicorn
./env/bin/pip install gunicorn
14.修改網站服務器運行文件run.py
vim run.py
去掉manager.run()
15.啓動gunicorn
./env/bin/gunicorn -w 4 -b 127.0.0.1:8080 --chdir ./ run:app
16.安裝nginx
yum install nginx
17.配置nginx
vim /etc/nginx/nginx.conf
18.重啓nginx
service nginx restart