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;
      }
相关推荐
司徒轩宇27 分钟前
Python secrets模块:安全随机数生成的最佳实践
运维·python·安全
用户785127814701 小时前
源代码接入 1688 接口的详细指南
python
vortex51 小时前
Python包管理与安装机制详解
linux·python·pip
辣椒http_出海辣椒2 小时前
如何使用python 抓取Google搜索数据
python
Ciel_75212 小时前
AmazeVault 核心功能分析,认证、安全和关键的功能
python·pyqt·pip
王国强20093 小时前
Python 异步编程的原理与实践
python
不枯石4 小时前
Python实现RANSAC进行点云直线、平面、曲面、圆、球体和圆柱拟合
python·计算机视觉
站大爷IP4 小时前
Python Lambda:从入门到实战的轻量级函数指南
python
深盾安全4 小时前
Python 装饰器精要
python
站大爷IP4 小时前
Python爬虫基本原理与HTTP协议详解:从入门到实践
python