0

i'm tring to deploy a simple flask script to a lighttpd server with fastcgi.

this is the configuration file for lighttpd builded using the flask documentation http://flask.pocoo.org/docs/deploying/fastcgi/#configuring-lighttpd

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

server.document-root        = "/var/www"
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"

index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                               " index.lighttpd.html" )

url.access-deny             = ( "~", ".inc" )

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

var.home_dir = "/var/lib/lighttpd"
var.socket_dir = home_dir + "sockets/"
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl"

dir-listing.encoding        = "utf-8"
server.dir-listing          = "enable"

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/x-javascript", "text/css", "text/html", "text/plain" )

include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"


fastcgi.server = ("weibo/callback.fcgi" =>
    ((  
        "socket" => "/tmp/weibocrawler-fcgi.sock",
        "bin-path" => "/var/www/weibo/callback.fcgi",
        "check-local" => "disable",
        "max-procs" => 1
    ))  
)

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

and this is the script i'm tring to run:

#!/home/nrl/kuro/weiboenv/bin/python
from flup.server.fcgi import WSGIServer
from callback import app 

if __name__ == '__main__':
    WSGIServer(application, bindAddress='/tmp/weibocrawler-fcgi.sock').run()

but i have this error testing the configuration file i get this error: 2013-07-02 17:15:42: (configfile.c.912) source: lighttpd.conf.new line: 52 pos: 1 parser failed somehow near here: weibo/callback.fcgi$1

when i remove the urlrewrite i get these errors in the log even if the daemon start:

2013-07-02 16:25:53: (log.c.166) server started 
2013-07-02 16:25:53: (mod_fastcgi.c.1104) the fastcgi-backend fcgi.py failed to start: 
2013-07-02 16:25:53: (mod_fastcgi.c.1108) child exited with status 2 fcgi.py 
2013-07-02 16:25:53: (mod_fastcgi.c.1111) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.
If this is PHP on Gentoo, add 'fastcgi' to the USE flags. 
2013-07-02 16:25:53: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed. 
2013-07-02 16:25:53: (server.c.938) Configuration of plugins failed. Going down.
1
  • where do you get /tmp/weibocrawler-fcgi.sock from ? or did you just manually typed in a path ? – Ciasto piekarz Oct 12 '19 at 12:47
0

You need to close the url.rewrite with a ).

That fcgi error seems to be referring to an fcgi script that I don't see mentioned in your configuration snippet. Is that the whole config? Is there anything in the conf.enabled directory?

1
  • this seem the right answer, i can now star correctly the server, i changed name to the application and then forgot to change it in one of the place where was named. i now get an error 500 but it's a separate issue, thanks – kurojishi Jul 9 '13 at 0:56
0

If you spawn the fcgi-app with lighttpd (bin-path option in the fastcgi.server block), the fcgi-app must not use the socket name (lighttpd will bind the socket to STDIN of the fcgi-app, and the fcgi-app usually detects this).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.