0

I'm trying to deploy my flask web app using lighttpd. I created this hello.fcgi file

#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from hello import app

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

And python file is hello.py

I added these lines at the end of the /etc/lighttpd/lighttpd.conf. I wanted it to be accessible from http://localhost:7777.

$SERVER["socket"] == ":7777" {
    fastcgi.server = ("/hello.fcgi" =>
        ((
            "socket" => "/tmp/hello-fcgi.sock",
            "bin-path" => "/var/www/html/py/hello.fcgi",
            "check-local" => "disable",
            "max-procs" => 1
        ))
    )

    alias.url = (
        "/static/" => "/var/www/html/py/static"
    )

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

I also enabled enable the FastCGI, alias and rewrite modules. All the files of my web app is located inside /var/www/html/py/ folder including hello.py , hello.fcgi and the "static" folder.

Then I restarted lighttpd and tried to visit http://localhost:7777 but my browser says "This site can’t be reached".

What is wrong here and how can I fix it?

  • I don't use lighttpd but have you tried accessing it using `http://127.0.0.1` rather than localhost? because generally, websites use virtual hosts to determine what the website should be accessible on which is different than 'listening' on all interfaces (IP addresses). – Simon Hayter Apr 17 '19 at 14:34
  • @SimonHayter Just tried `http://127.0.0.1:7777` , stll not working – user8481790 Apr 17 '19 at 14:48
  • @user8481790 check that lighttpd is actually running. It sounds like lighttpd is not running. Check the lighttpd error.log. There might be a syntax error in the config. Run `lighttpd -f /etc/lighttpd/lighttpd.conf -tt` to have lighttpd test and pre-flight the config (which will report errors to stderr, if errors are encountered). – gstrauss Feb 07 '20 at 05:34

0 Answers0