Flask+uwsgi+nginx项目部署【虚拟机】

一,安装mysql数据库,python

mysql数据库

[https://blog.csdn.net/ybw_2569/article/details/94767258]:

其中的第2,3,4,5步骤为安装mysql。
python

[https://blog.csdn.net/ybw_2569/article/details/89340883]:

二,确认centos IP 畅通

要确认服务器与客户之间相互ping通
ping 10.10.21.2

在这里插入图片描述

三,配置Flask环境

①关闭防火墙【学习步骤,在工作当中需要自己查询或者借助运维的同事开启对应的端口】
systemctl stop firewalld
setenforce 0
②在项目文件下生成package.txt文件

在这里插入图片描述

③将项目传到虚拟机
在此,使用的是Xftp

在这里插入图片描述

④配置flask环境
在虚拟机的项目文件下找到package.txt文件,进行flask环境的安装
pip3 install -r package.txt
⑤启动flask自带的服务器,进行测试
python3 manage.py runserver --host 0.0.0.0

在这里插入图片描述

四,配置uwsgi

① 安装uwsgi
pip3 install uwsgi
② 创建软连接
ln -s /usr/local/pytho3/bin/uwsgi /usr/bin/uwsgi
③创建uwsgi配置文件目录
mkdit /opt/script
vim uwsgi.ini
④编写配置
[uwsgi]

socket = 127.0.0.1:5000
pythonpath = /opt/BluePrintIntegration
module = manage
wsgi-file = /opt/BluePrintIntegration/manage.py
callable = app
processes = 4
threads = 2
daemonize = /opt/script/uwsgi.log
buffer-size = 43146
⑤启动uwsgi查看效果,【当前启动不能访问】

在这里插入图片描述

五,配置nginx

①安装nginx包,/opt下
wget -c https://nginx.org/download/nginx-1.12.2.tar.gz
②解压包
tar -zxvf nginx-1.12.2.tar.gz
③切换都nginx-1.12.2下,编译安装配置
/opt/nginx-1.12.2
./configure \
>回车

在这里插入图片描述

④编译安装
make && make install
⑤创建软连接
ln -s /usr/local/ngnix/sbin/nginx /usr/bin/nginx
⑥ 测试nginx

在这里插入图片描述

⑦配置nginx服务器,备份配置文件
/usr/local/nginx/conf ——》路径下
cp nginx.conf nginx.conf.bak
⑧ 进行配置
vim nginx.conf
server {
        listen       80;
        server_name  BluePrintIntegration; 
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        access_log /opt/script/flask.log;
        error_log /opt/script/flaskError.log;
        
        location / {
            include  uwsgi_params;
            uwsgi_pass 127.0.0.1:5000;

            uwsgi_param UWSGI_CHDIR /opt/BluePrintIntegration;
            uwsgi_param UWSGI_SCRIPT manage:app;
            }    
}

在这里插入图片描述)

⑨注意:nginx.conf与uwsgi.ini里的地址需要一致

在这里插入图片描述

⑩测试结果

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值