python - Apache 上的 Flask 应用程序,CentOs 抛出 mod_fcgid : error reading data from FastCGI server

标签 python apache flask centos mod-fcgid

我正在 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/

相关文章:

javascript - 使用按钮和 javascript 在 Flask 中设置 python 变量

python - 为 Django 模型 FloatField 设置最大默认值

python - 如何在不调用 `np.vectorize` 的情况下强制广播函数

python - 在python中计算范围内的用户输入数字

php - 简单的 .htaccess 重写不适用于 GoDaddy

python - 如何使用 SQLAlchemy 将 View 和表映射到一个模型?

heroku - 使用 Flask-Script 和 cron 作业

Python - 数组的坐标

node.js - 未处理的拒绝 SequelizeConnectionError : connect ENOENT

php - C/PHP : How do I convert the following PHP JSON API script into a C plugin for apache?