【发布时间】:2015-07-13 01:48:02
【问题描述】:
我正在基于 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>
【问题讨论】:
-
为什么你的
.fcgi文件中有打印语句?该错误是此“脚本头过早结束”的直接后果。 -
好的,这是几个月前的事了,我已经解决了(问题的确切根源是 python 模块在这个版本的 python 下不起作用,我将添加这个作为帮助的答案还有谁)。至于为什么我有打印语句,我在某处读到预期的脚本头只是一个内容类型的 html 头,只是试图部署一个简单的应用程序。
标签: python apache flask centos mod-fcgid