简体   繁体   English

在fastCGI apache服务器上安装Django时找不到错误日志

[英]Can't figure out error log when installing Django on fastCGI apache server

I get this error from the error log when trying to install Django on a FastCGI apache server. 尝试在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

I don't understand if the problem come from the server settings or my .fcgi code. 我不知道问题是否来自服务器设置或我的.fcgi代码。

.htaccess 的.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]

mysite.fcgi mysite.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")

I feel like the .fcgi code is ok since it run as expected when run from shell. 我觉得.fcgi代码还可以,因为它从shell运行时按预期运行。 If someone could help me get on the right path, it would really help out! 如果有人可以帮助我走上正确的道路,那真的会有所帮助!

Like Jordan said, it's a problem with the fcgi file. 就像乔丹所说的那样,这是fcgi文件的问题。

I was having the same problem trying to get Django working on bluehost. 我在尝试让Django在bluehost上工作时遇到了同样的问题。 A couple of things to check first are that the fcgi file is set to 755 and make sure your settings file is properly formatted by using: 首先要检查的几件事是将fcgi文件设置为755,并使用以下方法确保设置文件的格式正确:

python manage.py runserver

If those things are OK, try the solution I found at https://my.hostmonster.com/cgi/help/585 . 如果一切正常,请尝试在https://my.hostmonster.com/cgi/help/585上找到的解决方案。 From the directions there: 从那里的指示:

cd <fcgi directory>
unset PYTHONPATH
./mysite.fcgi

If you get a error like: 如果出现类似以下错误:

bad interpreter: No such file or directory

it means that the shebang (#!) line points to a file or directory that doesn't exist or that the fcgi was uploaded via ftp in binary mode instead of ascii. 这意味着shebang(#!)行指向不存在的文件或目录,或者fcgi是通过ftp而不是ascii二进制模式通过ftp上传的。

Try changing "the point of view": run the fcgi file as apache user (I'm sure there will be some interesting messages displayed). 尝试更改“观点”:以apache用户身份运行fcgi文件(我敢肯定会显示一些有趣的消息)。 Eg 例如

$ sudo su www-data
$ cd <fcgi directory>
$ ./mysite.fcgi

It's likely a problem with your .fcgi file, or even more likely, some trouble configuring your django site. .fcgi文件可能有问题,甚至更有可能是在配置django站点时遇到了一些麻烦。

Try running your .fcgi directly in a shell with ./mysite.fcgi. 尝试直接在具有./mysite.fcgi的外壳中运行.fcgi。 It should spit out some errors, which will give you something to troubleshoot with. 它应该吐出一些错误,这将给您带来一些疑难解答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM