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;
      }
相关推荐
电子_咸鱼15 小时前
【STL string 全解析:接口详解、测试实战与模拟实现】
开发语言·c++·vscode·python·算法·leetcode
哈茶真的c15 小时前
【书籍心得】左耳听风:传奇程序员练级攻略
java·c语言·python·go
io_T_T16 小时前
Paddle-CLS图像分类_环境安装
python·日常软硬件经验分享
百***480717 小时前
Python使用PyMySQL操作MySQL完整指南
数据库·python·mysql
PNP Robotics17 小时前
PNP机器人上海宝山智能机器人年会发表机器人10年主题演讲演讲
人工智能·python·机器人
___波子 Pro Max.17 小时前
Python获取当前脚本目录路径
python
努力成为大牛吧17 小时前
Pycharm 接入 Deepseek API完整版教程
ide·python·pycharm
闲人编程17 小时前
Python对象模型:一切都是对象的设计哲学
开发语言·python·模型·对象·codecapsule·下划线
二川bro17 小时前
Python大语言模型调优:LLM微调完整实践指南
开发语言·python·语言模型
wa的一声哭了17 小时前
Webase部署Webase-Web在合约IDE页面一直转圈
linux·运维·服务器·前端·python·区块链·ssh