当试图将Flask应用程序部署到我的LAMP服务器时,我发现了一个触发器的错误,一个FastCGI / WSGI网关,它使我的应用程序能够说出FastCGI协议。
〜/最小/ run.py
from flask import Flask from flipflop import WSGIServer app = Flask(__name__) @app.route('/') def hello_world(): return 'hello, world' if __name__ == '__main__': WSGIServer(app).run()
Apacheconfiguration文件的相关部分,即/etc/httpd/conf/httpd.conf :
<VirtualHost *:80> ScriptAlias / /home/apps/minimal/run.py ErrorLog /var/log/httpd/error_log </VirtualHost>
Apache / 2.2.15的错误报告:
[apps@kernod0 ~]$ sudo head -n 20 /var/log/httpd/error_log [sudo] password for apps: [Wed Aug 16 16:39:16 2017] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Wed Aug 16 16:39:16 2017] [notice] Digest: generating secret for digest authentication ... [Wed Aug 16 16:39:16 2017] [notice] Digest: done [Wed Aug 16 16:39:16 2017] [notice] Apache/2.2.15 (Unix) DAV/2 mod_fcgid/2.3.9 configured -- resuming normal operations [Wed Aug 16 16:39:16 2017] [error] [client 100.116.224.219] Traceback (most recent call last): [Wed Aug 16 16:39:16 2017] [error] [client 100.116.224.219] File "/home/apps/minimal/run.py", line 12, in <module> [Wed Aug 16 16:39:16 2017] [error] [client 100.116.224.219] WSGIServer(app).run() [Wed Aug 16 16:39:16 2017] [error] [client 100.116.224.219] File "/home/apps/minimal/flask/lib/python2.6/site-packages/flipflop.py", line 938, in run [Wed Aug 16 16:39:16 2017] [error] [client 100.116.224.219] sock.getpeername() [Wed Aug 16 16:39:16 2017] [error] [client 100.116.224.219] socket.error: [Errno 88] Socket operation on non-socket [Wed Aug 16 16:39:16 2017] [error] [client 100.116.224.219] Premature end of script headers: run.py [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.253] Traceback (most recent call last): [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.253] File "/home/apps/minimal/run.py", line 12, in <module> [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.253] WSGIServer(app).run() [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.253] File "/home/apps/minimal/flask/lib/python2.6/site-packages/flipflop.py", line 938, in run [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.253] sock.getpeername() [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.253] socket.error: [Errno 88] Socket operation on non-socket [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.253] Premature end of script headers: run.py [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.205] Traceback (most recent call last): [Wed Aug 16 16:39:17 2017] [error] [client 100.116.226.205] File "/home/apps/minimal/run.py", line 12, in <module>