尝试在 FastCGI apache 服务器上安装 Django 时,我从错误日志中收到此错误。
[Tue Feb 19 10:28:54 2013] [warn] [client 74.59.229.207] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Tue Feb 19 10:28:54 2013] [error] [client 74.59.229.207] Premature end of script headers: mysite.fcgi
[Tue Feb 19 10:28:54 2013] [error] [client 74.59.229.207] Premature end of script headers: 500.php
我不明白问题是来自服务器设置还是我的 .fcgi 代码。
.htaccess
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(adminmedia/.*)$ - [L]
RewriteCond %{REQUEST_URI} !(mysite.fcgi)
RewriteRule ^(.*)$ mysite.fcgi/$1 [L]
我的网站.fcgi
#!/usr/bin/python
import sys, os
sys.path.insert(0, "/home2/lacliniq/opt/python27/bin/python")
sys.path.insert(1, "/home2/lacliniq/opt/python27/lib")
os.chdir("/home2/lacliniq/public_html/checkupappdev")
os.environ['DJANGO_SETTINGS_MODULE'] = "firstaid.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
我觉得 .fcgi 代码没问题,因为它在从 shell 运行时按预期运行。如果有人可以帮助我走上正确的道路,那真的会有所帮助!