1、使用linux系统安装宝塔BT

https://www.bt.cn/new/download.html
这里我是Centos系统,对应的安装脚本是
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh ed8484bec
完事后进入宝塔面板,默认安装LNMP,等安装完毕,网站前端配置环境基本完成。

2、打开软件商店,搜索Python,然后安装Python项目管理器,点击设置 版本管理安装3.8.5

3、使用putty链接上centos

[root@localhost]# python -V
Python 2.7.5               查看pythone版本
[root@localhost]# pyenv versions
* system (set by /root/.pyenv/version)
  3.8.5                    已经安装的版本
[root@localhost]# pyenv global 3.8.5
[root@localhost]# python -V
Python 3.8.5               设置全局版本为3.8.5
[root@localhost]# pip install requests 
[root@localhost]# pip install Flask
[root@localhost]# pip install gunicorn
安装三个依赖,
如果提示pip报错,如下所示
WARNING: You are using pip version 20.3.3; however, version 22.3.1 is available.
You should consider upgrading via the '/www/server/panel/pyenv/bin/python3.7 -m pip install --upgrade pip' command.
[root@localhost]# /www/server/panel/pyenv/bin/python3.7 -m pip install --upgrade pip
则升级一下pip

4、新建2个网站,域名随意,如果是内网使用,假的域名也可以。 假设前端是A.cn,后端是B.cn 将前端文件夹内容上传到A.cn 根目录下,原有的初始文件删除; 将后端文件夹内容上传到B.cn 根目录下,原有的初始文件删除; 修改前端文件夹下的js/function.js 的 https://vhapi.com 替换成 http://B.cn 一共有六个地方,可以查找提换 在B.cn 右边有个设置-反向代理 代理名称 随意 目标URL http://127.0.0.1:5200 发送 域名 $host 5、由于域名是虚假的,你想要在本机下访问,请修改host记录

C:\Windows\System32\drivers\etc\hosts
如果提示不能保存,请获取管理员权限。
在里面添加2行记录
192.168.1.X A.cn
192.168.1.X B.cn
注释:192.168.1.X 为你linux ip地址,具体可以查看路由器

6、最后一步,运行后端,putty链接上linux服务器,输入账密后

cd /www/wwwroot/B.cn      打开后端目录
gunicorn -w 3 -b 0.0.0.0:5200 -D xiaomiWeb:app

7、浏览器输入A.cn应该可以访问到地址了。

Editing is enabled. Use the "Save changes" button below the editor to commit modifications to this file.