10-tornado项目部署

1. python3的安装和配置

1.1 安装系统依赖包

shell 复制代码
sudo dnf install wget yum-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel -y

1.2 下载Python

shell 复制代码
wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz

1.3 解压

python 复制代码
tar xzf Python-3.9.5.tgz 

1.4 安装

shell 复制代码
cd Python-3.9.5
sudo ./configure --enable-optimizations --prefix=/usr/local/python3.9
sudo make install

1.5 配置python环境变量

shell 复制代码
# 让系统识别python3.9 修改~/.bash_profile
PATH=/opt/python3.9/bin
. ~/.bash_profile

1.6 删除解压文件

python 复制代码
sudo rm Python-3.9.5.tgz

2. 虚拟环境

2.1 安装

shell 复制代码
pip3 install virtualenvwrapper

2.2 配置

shell 复制代码
# 查找virtualenvwrapper.sh脚本的路径
find / -name virtualenvwrapper.sh

export PATH
# 让系统识别virtualenv 修改~/.bash_profile
export WORKON_HOME=~/python_env
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.9
source /usr/local/python3/bin/virtualenvwrapper.sh

2.3 配置生效

shell 复制代码
source ~/.bash_profile

2.4 新建虚拟环境

shell 复制代码
mkvirtualenv tornado_env

3. mysql的安装和配置

3.1 安装

shell 复制代码
 dnf install @mysql -y

3.2 开机启动

shell 复制代码
systemctl enable --now mysqld

3.3 启动MySQL服务

shell 复制代码
systemctl status mysqld

3.4 添加密码及安全设置

shell 复制代码
mysql_secure_installation
  • 要求你配置VALIDATE PASSWORD component(验证密码组件): 输入y ,回车进入该配置

  • 选择密码验证策略等级, 我这里选择0 (low),回车

  • 输入新密码两次

  • 确认是否继续使用提供的密码?输入y ,回车

  • 移除匿名用户? 输入y ,回车

  • 不允许root远程登陆? 我这里需要远程登陆,所以输入n ,回车

  • 移除test数据库? 输入y ,回车

  • 重新载入权限表? 输入y ,回车

3.5 配置远程登录

shell 复制代码
mysql -uroot -p<上面步骤中设置的密码>
use mysql;
update user set host='%' where user='root';
flush privileges;

4. redis安装与配置

4.1 安装

shell 复制代码
dnf install redis -y

4.2 开启redis与 开机启动

shell 复制代码
systemctl start redis
systemctl enable redis

4.3 测试

shell 复制代码
systemctl status redis
redis-cli

5. Nginx的安装

5.1 安装

shell 复制代码
sudo dnf install nginx -y

5.2 开机启动与开启服务

shell 复制代码
sudo systemctl enable nginx
sudo systemctl start nginx

6. tornado的项目部署

  1. 上传tornado代码

  2. 初始化数据

  3. 启动项目

  4. 修改Nginx。 追加内容

shell 复制代码
  http {
      # 在upstream中列出所有的tornado server,当然如果你要做不同的路由跳转的时候可以定义多个upstream
      upstream tornado {
          server 127.0.0.1:8000;
          server 127.0.0.1:8001;
          server 127.0.0.1:8002;
          server 127.0.0.1:8003;
      }
    server {
      location / {
          proxy_pass http://tornado;
      }
相关推荐
databook1 天前
Manim实现脉冲闪烁特效
后端·python·动效
程序设计实验室1 天前
2025年了,在 Django 之外,Python Web 框架还能怎么选?
python
倔强青铜三1 天前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试
用户2519162427111 天前
Python之语言特点
python
刘立军1 天前
使用pyHugeGraph查询HugeGraph图数据
python·graphql
数据智能老司机1 天前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
数据智能老司机2 天前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i2 天前
django中的FBV 和 CBV
python·django
c8i2 天前
python中的闭包和装饰器
python
这里有鱼汤2 天前
小白必看:QMT里的miniQMT入门教程
后端·python