zoukankan      html  css  js  c++  java
  • 雷林鹏分享Flask FastCGI

      FastCGI是Web服务器(如nginix,lighttpd和Cherokee)上Flask应用程序的另一个部署选项。

      配置FastCGI

      首先,需要创建FastCGI服务器文件,例如它的名称为:yourapplication.fcgiC 。

      from flup.server.fcgi import WSGIServer

      from yourapplication import app

      if __name__ == '__main__':

      WSGIServer(app).run()

      nginx和较早版本的lighttpd需要明确传递一个套接字来与FastCGI服务器进行通信。需要将路径传递给WSGIServer的套接字。

      WSGIServer(application, bindAddress = '/path/to/fcgi.sock').run()

      配置Apache

      对于基本的Apache部署,.fcgi 文件将出现在您的应用程序URL中,例如http://example.com/yourapplication.fcgi/hello/。 有以下几种方法来配置应用程序,以便yourapplication.fcgi不会出现在URL中。

      

      ServerName example.com

      ScriptAlias / /path/to/yourapplication.fcgi/

      

      配置lighttpd

      lighttpd的基本配置看起来像这样 -

      fastcgi.server = ("/yourapplication.fcgi" => ((

      "socket" => "/tmp/yourapplication-fcgi.sock",

      "bin-path" => "/var/www/yourapplication/yourapplication.fcgi",

      "check-local" => "disable",

      "max-procs" => 1

      )))

      alias.url = (

      "/static/" => "/path/to/your/static"

      )

      url.rewrite-once = (

      "^(/static($|/.*))$" => "$1",

      "^(/.*)$" => "/yourapplication.fcgi$1"

      )

      请记住启用FastCGI,别名和重写模块。 该配置将应用程序绑定到/yourapplication。(编辑:雷林鹏 来源:网络 侵删)

  • 相关阅读:
    Vpython简单例子
    我在读的书:《ACM图灵奖:19662006(第三版)计算机发展史的缩影》
    可惜啊,没见到姚期智~~
    The Sounds of Music 观后感
    终于在博客园申请开通博客了
    【引用】Python open读写文件实现脚本
    在Python中使用中文
    Discovery:深入理解计算机系统 (Ver.2) 中文版
    [导入]一个都不能少:全面认识IE插件
    [导入]午间心情
  • 原文地址:https://www.cnblogs.com/pengpeng1208/p/11394109.html
Copyright © 2011-2022 走看看