zoukankan      html  css  js  c++  java
  • apache+flask部署

    wsgi方式

    1.安装apache

    1.解压httpd并进行安装

        # tar zxvf httpd-2.2.15.tar.gz

        # cd httpd-2.2.15
        # ./configure --prefix=/opt/oracle/apache --enable-rewrite --enable-so(大约两分钟,选项的作用主要是允许动态加载模块,以后我们要加载mod_wsgi)
        # make
        # make install

    2.启动apache服务
        # /opt/oracle/apache/bin/apachectl start

    3.测试
        # curl 127.0.0.1
    当看到"It works"代表apache配置成功

    2.安装mod_wsgi
    1.解压,安装

        #mkdir /var/run/mod_wsgi
        # tar zxvf mod_wsgi-3.3.tar.gz 
        # cd mod_wsgi-3.3/
        # ./configure --with-apxs=/opt/oracle/apache/bin/apxs(apache动态添加的一个模块)
                           --with-python=/usr/bin/python(指定python的路径)
                           --with-mutex-dir=/var/run/mod_wsgi(最大缓冲值的目录)
        # make 在这一步如果出现make: *** [mod_wsgi.la]错误则需要重新编译安装python2.7并加上--enable-shared参数.
        # make install

    2.配置Apache

    httpd.conf去除如下行的注释

    #Include conf/extra/httpd-vhosts.conf

    httpd.conf修改DocumentRoot到程序所在目录

    DocumentRoot "/opt/oracle/apache/htdocs/ROOT/panoramic"

    3.修改Virtual Host配置

    NameVirtualHost *

    LoadModule wsgi_module modules/mod_wsgi.so

    <VirtualHost *>
    ServerName localhost
     
    WSGIDaemonProcess flask_web threads=30
    WSGIProcessGroup flask_web
    WSGIScriptAlias /monitor/panoramic /opt/oracle/apache/htdocs/ROOT/panoramic/monitor.wsgi
     
    <Directory /opt/oracle/apache/htdocs/ROOT/panoramic>
    WSGIProcessGroup flask_web
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
    </Directory>
    </VirtualHost>

    4.创建测试页面

    创建flask_web.py脚本

    monitor.wsgi内容如下

    import sys
    sys.path.insert(0, '/opt/oracle/apache/htdocs/ROOT/panoramic')
    from monitor import app as application

    重启apache访问IP/app

    cgi方式

    首先,你需要创建 CGI 应用文件。我们把它命名为 yourapplication.cgi:
    #!/usr/bin/python
    from wsgiref.handlers import CGIHandler
    from flask_web import app
    CGIHandler().run(app)

    配置httpd.conf

    ScriptAlias /monitor/panoramic  "/opt/oracle/apache/htdocs/ROOT/panoramic/flask_web.cgi"

    httpd.conf修改DocumentRoot到程序所在目录

    DocumentRoot "/opt/oracle/apache/htdocs/ROOT/panoramic"

  • 相关阅读:
    CentOS7.6配置ip
    查看当前用户下没有主键也没有唯一性索引的表
    C++ 开机自动启动
    C++ 判断是文件还是文件夹
    Duilib热键
    c++将字符转换成字符串
    duilib中各控件响应的消息类型
    Duilib程序添加托盘图标显示
    C++打开文件夹
    C++获取驱动盘句柄
  • 原文地址:https://www.cnblogs.com/Monitor/p/4505959.html
Copyright © 2011-2022 走看看