简体   繁体   中英

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.

[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.

.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

#!/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. 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.

I was having the same problem trying to get Django working on 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:

python manage.py runserver

If those things are OK, try the solution I found at 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.

Try changing "the point of view": run the fcgi file as apache user (I'm sure there will be some interesting messages displayed). 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.

Try running your .fcgi directly in a shell with ./mysite.fcgi. It should spit out some errors, which will give you something to troubleshoot with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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