[英]FastCGI, Apache, Django and 500 Error
我在使用Apache和FastCGI时遇到500内部错误。 一整天都在寻找原因:-/
FastCGIExternalServer /home/me/web/mysite.fcgi -socket /home/me/web/mysite.sock
Listen 80
<VirtualHost *:80>
ServerName os.me #That's my localhost machine
DocumentRoot /home/me/web
Alias /media/ /home/me/develop/projects/media
<Directory "/home/me/web">
AllowOverride All
Allow from all
Order allow,deny
</Directory>
</VirtualHost>
Options +Indexes +FollowSymlinks
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
#!/usr/bin/python
import sys, os
os.chdir("/home/me/develop/projects/mysite")
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded",daemonize="false")
...
[Sat Aug 07 01:41:13 2010] [error] [client 127.0.0.1] (2)No such file or directory: FastCGI: failed to connect to server "/home/me/web/mysite.fcgi": connect() failed
[Sat Aug 07 01:41:13 2010] [error] [client 127.0.0.1] FastCGI: incomplete headers (0 bytes) received from server "/home/me/web/mysite.fcgi"
.fcgi文件的执行(它作为html页面的状态为“ 200 OK”,并按应有的方式呈现):
me@os ~/web $ python mysite.fcgi
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/html
...
感谢#django irc频道的帮助(特别是zk)。
FastCGIExternalServer /home/me/web/mysite.fcgi -socket /home/me/web/mysite.sock
必须更改为(因为apache应该生成fcgi进程本身):
FastCGIServer /home/me/web/mysite.fcgi -socket /home/me/web/mysite.sock
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.