1.申请云主机
a.阿里云 (注意:阿里云的服务器需要手动添加安全规则使能80端口)
b.腾讯云
2.把网站服务器程序拷贝到云主机
3.远程登录云主机
4.解压网站服务器程序
yum install bzip2
tar -xvf 03IotServer.tar.bz2
5.安装Python3
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