Chinaunix

标题: flask 的部署问题 [打印本页]

作者: ccz2005    时间: 2010-06-09 17:12
标题: flask 的部署问题
本帖最后由 ccz2005 于 2010-06-10 13:01 编辑

看了flask,根据它的文档 进行部署,用lighttpd,fcgi,不成功, 有哪位高手帮帮忙,
官方文档十分简略:
Creating a .fcgi file
First you need to create the FastCGI server file. Let’s call it yourapplication.fcgi:

  1. #!/usr/bin/python
  2. from flup.server.fcgi import WSGIServer
  3. from yourapplication import app
  4. WSGIServer(app).run()
复制代码
This is enough for Apache to work, however lighttpd and nginx need a socket to communicate with the FastCGI server. For that to work you need to pass the path to the socket to the WSGIServer:

WSGIServer(application, bindAddress='/path/to/fcgi.sock').run()
The path has to be the exact same path you define in the server config.

Save the yourapplication.fcgi file somewhere you will find it again. It makes sense to have that in /var/www/yourapplication or something similar.

Make sure to set the executable bit on that file so that the servers can execute it:

# chmod +x /var/www/yourapplication/yourapplication.fcgi
Configuring lighttpd
A basic FastCGI configuration for lighttpd looks like that:
  1. fastcgi.server = ("/yourapplication" =>
  2.     "yourapplication" => (
  3.         "socket" => "/tmp/yourapplication-fcgi.sock",
  4.         "bin-path" => "/var/www/yourapplication/yourapplication.fcgi",
  5.         "check-local" => "disable"
  6.     )
  7. )
复制代码
This configuration binds the application to /yourapplication. If you want the application to work in the URL root you have to work around a lighttpd bug with the LighttpdCGIRootFix middleware.

Make sure to apply it only if you are mounting the application the URL root.


上面的lighttpd的配置是有错误的,我在lighttpd上部署不成功
作者: jjj137    时间: 2010-06-09 23:55
虽然不懂这个,不过你最好还是说明具体的部署环境与过程,以及结果,以便他人分析。
作者: newcnad    时间: 2010-06-10 10:46
回复 2# jjj137


    对,最好把遇见的问题也罗列一下
作者: cc520    时间: 2010-06-10 19:47
flup 安装了没?
作者: ccz2005    时间: 2010-06-10 23:12
flup已经安装
作者: yyliuliang    时间: 2010-06-29 15:50
flask 走fastcgi我已经部署成功了 但是nginx的path_info 导致 url routing有bug
详情看这里 http://www.yyliuliang.cn/posts/f ... st-cgi-incompleted/




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2