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?
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).http://127.0.0.1:7777
, stll not workinglighttpd -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).