使用Lighttpd进行烧瓶部署

时间:2019-03-12 03:22:15

标签: python flask lighttpd

尝试启动lighttpd服务时出现以下错误。

请帮助我解决此问题。添加.fcgi时,我遇到了此类问题。

fastcgi后端无法启动:

孩子以状态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"
)

0 个答案:

没有答案