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>