
fastcgi를 사용하여 Python 응용 프로그램을 실행하려는 lighttpd 서버가 있습니다. 나는 따라 갔다lighty 홈페이지의 예, 하지만 Python 스크립트를 실행하기가 쉽지 않은 것 같습니다. 이것은 lighttpd.conf의 fastcgi 섹션입니다:
fastcgi.server = (
".py" =>
(
"python-fcgi" =>
(
"socket" => "/tmp/fastcgi.python.socket",
"bin-path" => "/usr/bin/login_flask/fcgitest.py",
"check-local" => "disable",
"max-procs" => 1,
)
))
fcgitest.py의 내용은 다음과 같습니다.
#!/usr/bin/python3
def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp, bindAddress="/tmp/fastcgi.python.socket").run()
이 구성으로 lighty를 다시 시작하면 python 프로세스가 시작되고 lighty에서 오류가 발생하지 않는 것을 볼 수 있습니다. 그런데 제가 갔을 때https://localhost:444/test.py영원히 계속 로드됩니다. access.log나 error.log에는 아무 것도 기록되지 않습니다. 누군가 나에게 이 문제를 조사하는 방법에 대한 힌트를 줄 수 있다면 감사하겠습니다.
편집: fastcgi.debug를 활성화했는데 위에서 언급한 URL로 이동하면 오류 로그에 이 내용이 기록됩니다. 여전히 영원히 계속 로드됩니다.
2019-07-26 11:53:26: (gw_backend.c.914) gw - found a host 0
2019-07-26 11:53:26: (gw_backend.c.227) got proc: pid: 2628 socket: unix:/tmp/fastcgi.python.socket-0 load: 1
답변1
귀하의 fcgitest.py
,
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp, bindAddress="/tmp/fastcgi.python.socket").run()
예제에는 bindAddress
여기에 있는 매개변수가 포함되어 있지 않습니다.
대신 이것을 시도해 보세요.
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()