Apache+mod_wsgi+Flask部署文档--ubuntu

本文档适用于:

  1. python3.5

  2. apache2.4

  3. mod_wsgi4.3

部署过程:

  1. 安装Apache

    $ sudo apt-get install apache2
    

    启动apache服务

    $ sudo /etc/init.d/apache2 start
    
  2. 安装mod_wsgi

    $ sudo apt-get install libapache2-mod-wsgi-py3
    

    如果项目开发使用的是python2,则不需要加-py3

    启动mod_wsgi

    $ sudo a2enmod wsgi
    
  3. 创建.wsgi文件,该文件用于启动项目,如下

    import os
    import sys
    import re
    
    //进入虚拟环境,相当于souce .venv/bin/active
    activate_this = '/home/sam/Snipe/.venv/bin/activate_this.py'
    with open(activate_this) as file_:
        exec(file_.read(), dict(__file__=activate_this))
    
    //这里需要导入环境变量
    
    from app import app as application
    
  4. 创建apache配置文件,配置虚拟主机,将配置文件添加到/etc/apache2/sites-available/,如下

    <VirtualHost 172.18.215.158:5000>
        ServerAdmin xiemsinsysu@
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值