CentOS7 部署flask和paddleX

CentOS7 部署flask和paddleX

1、官网下载anaconda,部署python环境

#权限
chmod +x Anaconda3-2020.11-Linux-x86_64.sh

#安装anaconda
bash Anaconda3-2020.11-Linux-x86_64.sh

#生效启动conda
source ~/.bashrc

#创建虚拟环境
conda create -n web_dev python=3.7

#激活虚拟环境 web_dev
conda activate web_dev

#退出虚拟环境
conda deactivate

#conda配置国内镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

#pip设置国内镜像
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

2、部署 flask

#在虚拟环境内
#安装pip
pip install flask

#或采用requirements.txt文件部署
pip install pipreqs
pipreqs ./
pip install -r requirements.txt

3、部署paddleX

#在虚拟环境内
#安装paddlepaddle 安装1.3paddleX 需1.8.5版本paddelpaddle
pip install paddlepaddle==1.8.5 -i https://mirror.baidu.com/pypi/simple

#安装其他依赖
pip install common dual tight data prox -i https://mirror.baidu.com/pypi/simple

#安装paddle
pip install paddle -i https://mirror.baidu.com/pypi/simple

#安装paddleX
pip install paddlex -i https://mirror.baidu.com/pypi/simple

#安装依赖库
yum install libSM-1.2.2-2.el7.x86_64 --setopt=protected_multilib=false
yum install libSM.x86_64
yum install libXext.x86_64
yum install libXrender.x86_64

#后台启动
nohup gunicorn -w 2 -b 0.0.0.0:8081  app:app &

4、部署nginx

#安裝epel-release
yum install epel-release

#安裝nginx
yum install nginx

#启动
systemctl start nginx

#停止
systemctl stop nginx

#重载conf
systemctl reload nginx

配置nginx.conf(文件默认在/etc/nginx)

server {
    listen       *端口号*;
    server_name  localhost;

    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
	
	#跨域
    location / {
        index  index.html index.htm;
        add_header Access-Control-Allow-Origin *;
        add_header 'Access-Control-Allow-Headers' 'Authorization,authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Requested-With';
    }

    error_page 404 /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值