我正在 Apache 和 Mysql 上的 CentOS 6.6 上开发 Flask 应用程序。它修改自 The Flask Megatutorial .我能够正常创建数据库,但是当我尝试从我的浏览器访问它时,我收到 500 内部服务器错误,这在 error_log 文件中:
content type: text/html
<h1>Hello world!</h1>
[Sun May 03 18:39:53 2015] [error] [client my.ip.add.res] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Sun May 03 18:39:53 2015] [error] [client my.ip.add.res] Premature end of script headers: runp-mysql.fcgi
这是在我将 runp-mysql.fcgi 文件编辑成这样之后:
#!flask/bin/python
#encoding=UTF-8
#import os
print "content type: text/html\n\n"
print ""
print "<h1>Hello world!</h1>"
从命令行运行它正确完成。
我的 httpd.conf 文件以此结尾:
FcgidIPCDir /tmp
AddHandler fcgid-script .fcgi
<VirtualHost *:80>
DocumentRoot /home/apps/my_app/app/static
Alias /static /home/apps/my_app/app/static
ScriptAlias / /home/apps/my_app/runp-mysql.fcgi/
</VirtualHost>
最佳答案
我也在做同样的事情,主要问题是文件的权限。确保它是可执行的而不是只读的。
我也不认为 runp-mysql.fcgi 是您要进行打印的地方。它应该在 View 文件中。这是您应该连接到您的 mysql 数据库然后启动 wscgi 服务器的地方。
关于python - Apache 上的 Flask 应用程序,CentOs 抛出 mod_fcgid : error reading data from FastCGI server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30017191/