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;
      }
相关推荐
try2find13 分钟前
安装llama-cpp-python踩坑记
开发语言·python·llama
博观而约取1 小时前
Django ORM 1. 创建模型(Model)
数据库·python·django
精灵vector3 小时前
构建专家级SQL Agent交互
python·aigc·ai编程
Zonda要好好学习3 小时前
Python入门Day2
开发语言·python
Vertira3 小时前
pdf 合并 python实现(已解决)
前端·python·pdf
太凉3 小时前
Python之 sorted() 函数的基本语法
python
项目題供诗3 小时前
黑马python(二十四)
开发语言·python
晓13134 小时前
OpenCV篇——项目(二)OCR文档扫描
人工智能·python·opencv·pycharm·ocr
是小王同学啊~4 小时前
(LangChain)RAG系统链路向量检索器之Retrievers(五)
python·算法·langchain
AIGC包拥它4 小时前
提示技术系列——链式提示
人工智能·python·langchain·prompt