Linux部署Tcloud云测平台(源码部署)

1、基础环境准备

Centos7、python3.8.6、nginx1.9.9、node14.3.0

2、安装python

2.1、安装依赖

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install gcc
yum install libffi-devel -y
yum install mysql-devel

2.2、下载源码包

wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tgz

2.3、解压安装

mkdir /usr/local/python3
tar xvf Python-3.8.6.tgz
cd Python-3.8.6
./configure --prefix=/usr/local/python3
make
make install
ln -s /usr/local/python/bin/python3 /usr/bin/python3
ln -s /usr/local/python/bin/pip3 /usr/bin/pip3

3、部署后端(源码部署)

3.1、下载源码

git clone https://github.com/JunManYuanLong/TcloudServer.git

3.2、修改requirement.txt文件

flask==1.1.2
pyyaml==5.4.1
flask-sqlalchemy==2.4.4
flask-marshmallow==0.14.0
flask-script==2.0.6
flask-cors==3.0.2
flask-apscheduler==1.11.0
flask-caching==1.9.0
flask-login==0.5.0
gunicorn==20.0.4
ipython==7.19.0
pyjwt==1.7.1
gevent==21.1.2
marshmallow-sqlalchemy==0.24.1
xlrd==2.0.1
xlwt==1.3.0
requests==2.25.1
oss2==2.13.1
httprunner==1.5.13
ordereddict==1.1
urllib3==1.26.2
python-jenkins==1.7.0
mysqlclient==2.0.3
pandas==0.24.2
jira==2.0.0
tornado==6.1
ujson==4.0.1
aredis==1.1.8
redis==3.5.3
pymysql==1.0.2

3.3、安装依赖

pip3 install -r requirement.txt

安装依赖过程中,mysqlclient可能会出差,有时候安装mysqlclient‑1.4.6‑cp38‑cp38‑win_amd64.whl不生效,不妨试试mysqlclient‑1.4.6‑cp38‑cp38‑win32.whl,32位生效,就是这么神奇。

3.4、修改local_config.py文件

SQLALCHEMY_DATABASE_URI = 'mysql://root:root@:3306/demo?charset=utf8'

4、部署前端

4.1、安装node

wget https://nodejs.org/dist/v14.3.0/node-v14.3.0-linux-x64.tar.xz
tar -xvf node-v14.3.0-linux-x64.tar.xz
mv node-v14.3.0-linux-x64 /usr/local/node
ln -s /usr/local/node/bin/node /usr/bin/node
ln -s /usr/local/node/bin/npm /usr/bin/npm
npm config set registry https://registry.npm.taobao.org
npm install yarn
ln -s /usr/local/node/bin/yarn /usr/bin/yarn
ln -s /usr/local/node/bin/yarnpkg /usr/bin/yarnpkg

4.2、下载前端源码

git clone https://github.com/JunManYuanLong/Tcloud.git

4.3、安装依赖包

yarn install

4.4、编译打包

yarn run build

5、安装nginx

wget https://nginx.org/download/nginx-1.9.9.tar.gz
tar -zxvf nginx-1.9.9.tar.gz
./configure --prefix=/usr/local/nginx
make
make install
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx

5.1、配置代理

更改nginx.conf文件

server {
    listen 80;
    server_name 127.0.0.1 localhost 192.168.245.128;

  location /v1/datashow/ {
        proxy_pass http://127.0.0.1:9022;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }
    location /v1/jobs/ {
        proxy_pass http://127.0.0.1:9038;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }
       location /v1/message/ {
        proxy_pass http://127.0.0.1:9030;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location /v1/tcdevices/ {
        proxy_pass http://127.0.0.1:9036;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location  /v1/public/ {
        proxy_pass http://127.0.0.1:9034;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location  /v1/monkey/ {
        proxy_pass http://127.0.0.1:9022;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location ~* /v1/(flow|deploy)/ {
        proxy_pass http://127.0.0.1:9026;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location ~* /v1/(cidata|tool)/ {
        proxy_pass http://127.0.0.1:9024;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location ~* /v1/interface.* {
        proxy_pass http://127.0.0.1:9028;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location ~* /v1/(user|track|role|ability|feedback|wxlogin)/ {
        proxy_pass http://127.0.0.1:9020;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }

    location / {
        proxy_pass http://127.0.0.1:9032;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, projectid';
        add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';

    }
}

server {
    listen       8080;
    server_name  192.168.245.128;

    location / {
        root   /home/Tcloud/dist/build;
        index  index.html index.htm;
    }
}

5.3、启动nginx

nginx

 

你可能感兴趣的:(云测试,Tcloud)