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;
      }
相关推荐
JUNAI_Strive_ving10 分钟前
番茄小说逆向爬取
javascript·python
彤银浦11 分钟前
python学习记录7
python·学习
简单.is.good32 分钟前
【测试】接口测试与接口自动化
开发语言·python
Envyᥫᩣ1 小时前
Python中的自然语言处理:从基础到高级
python·自然语言处理·easyui
哪 吒1 小时前
华为OD机试 - 几何平均值最大子数(Python/JS/C/C++ 2024 E卷 200分)
javascript·python·华为od
我是陈泽1 小时前
一行 Python 代码能实现什么丧心病狂的功能?圣诞树源代码
开发语言·python·程序员·编程·python教程·python学习·python教学
hakesashou1 小时前
python全栈开发是什么?
python
创作小达人1 小时前
家政服务|基于springBoot的家政服务平台设计与实现(附项目源码+论文+数据库)
开发语言·python
ZPC82102 小时前
Python使用matplotlib绘制图形大全(曲线图、条形图、饼图等)
开发语言·python·matplotlib
镜花照无眠2 小时前
Python爬虫使用实例-mdrama
开发语言·爬虫·python