【问题标题】:Flask deployment with Lighttpd使用 Lighttpd 部署烧瓶
【发布时间】:2019-03-12 03:22:14
【问题描述】:

我在尝试启动 lig​​httpd 服务时遇到以下错误。

请帮我解决这个问题。在添加 .fcgi 时,我遇到了这样的问题。

fastcgi-backend 启动失败:

孩子以状态 1 退出

生成 fcgi 失败。

test.fcgi 文件:


#!/usr/bin/python

from flup.server.fcgi import WSGIServer
from test import app

class ScriptNameStripper(object):
   def __init__(self, app):
       self.app = app

   def __call__(self, environ, start_response):
       environ['SCRIPT_NAME'] = ''
       return self.app(environ, start_response)

app = ScriptNameStripper(app)

if __name__ == '__main__':
    WSGIServer(app).run()

test.py 文件:

from flask import Flask
from flask import render_template

app = Flask(__name__)

@app.route('/')
def runit():
    return render_template('index.html')

@app.route('/signup')
def signup():
    return render_template('signup.html')

if __name__ == '__main__':
    app.run()

Lightppd.conf:

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    "mod_cgi",
    "mod_fastcgi",
    "mod_rewrite"
)

server.document-root        = "/home/jpk/Examples/test"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 8080


fastcgi.server = ("/test.fcgi" =>
    ((
        "socket" => "/tmp/yourapplication-fcgi.sock",
        "bin-path" => "/home/jpk/Examples/test/test.fcgi",
        "check-local" => "disable",
        "max-procs" => 1
    ))
)

alias.url = (
    "/static/" => "/static/"
)

url.rewrite-once = (
    "^(/static($|/.*))$" => "$1",
    "^(/.*)$" => "/test.fcgi$1"
)

【问题讨论】:

    标签: python flask lighttpd


    【解决方案1】:

    尝试从命令行运行您的 test.cgi。如果你得到类似的东西:

    ImportError: No module named flup.server.fcgi
    

    那么你需要安装flup才能使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-24
      • 2016-03-19
      • 1970-01-01
      • 2019-02-10
      • 2021-05-31
      • 2015-07-15
      • 2012-08-03
      • 1970-01-01
      相关资源
      最近更新 更多