Lighttpd + Django配置 - “等待连接”
我想把Lighttpd和Django配置在一起,让它在localhost:3033上显示一个基本的“你好,世界”Django网站(这个网站是通过 $ django-admin startproject hellodjango
创建的)。我按照文档的说明操作,但我的网站就是无法正常工作。访问localhost:3033后,什么都没有发生,我只看到“等待连接”的信息。
我的lighttpd.config文件内容是:
server.groupname = "www-data"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm",
" index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl"
dir-listing.encoding = "utf-8"
server.dir-listing = "enable"
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" )
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
# My configuration
$HTTP["host"] == "www.hellodjango.com" {
server.document-root = "/home/krris/programowanie/django/hellodjango"
server.errorlog = "/home/krris/programowanie/django/hellodjango/logs/error.log"
accesslog.filename = "/home/krris/programowanie/django/hellodjango/logs/access.log"
fastcgi.server = (
"/hellodjango.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP fastcgi
"host" => "127.0.0.1",
"port" => 3033,
# "socket" => "/home/krris/hellodjango.sock",
"check-local" => "disable",
)
),
)
alias.url = (
"/media/" => "/home/krris/programowanie/django/hellodjango/media/",
)
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/hellodjango.fcgi$1",
)
}
hellodjango.fcgi文件内容是:
#!/usr/bin/python
import sys, os
# Add a custom Python path.
sys.path.insert(0, "..")
# Switch to the directory of your project. (Optional.)
os.chdir("/home/krris/programowanie/django/hellodjango")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "hellodjango.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="prefork", daemonize="true", host="127.0.0.1", port="3033")
我还在settings.py文件中添加了这一行:
FORCE_SCRIPT_NAME = ""
我用以下命令运行我的应用:
$ ./manage.py runfcgi method=prefork host=127.0.0.1 port=3033
error.log:日志内容是:
2013-03-19 11:27:10: (log.c.166) server started
2013-03-19 11:27:16: (server.c.1396) [note] graceful shutdown started
2013-03-19 11:27:16: (log.c.166) server started
2013-03-19 11:27:16: (server.c.1512) server stopped by UID = 0 PID = 8093
我使用的是Ubuntu 12.10系统。
2 个回答
0
我试过你刚才做的事情。还有一个我发现能让这个工作(我觉得)的方法是确保:
- .fcgi 文件对所有人都有执行权限。
- 日志文件夹也必须有权限。
不过我看到的只是项目文件夹的文件列表。 你也是这样吗? 而且我通过 www.helloDjango.com 的网址也无法正常工作。
请告诉我你是否得到了相同的结果。 我发现要让一个简单的 hello world 页面运行起来真的很困难,也很让人困惑。
0
你的服务器因为某种原因停止了运行。一个可能的调试方法是在这里设置 daemonize="false":
runfastcgi(method="prefork", daemonize="true", host="127.0.0.1", port="3033")
这样做可能会帮助你了解发生了什么,以及为什么你的服务器会关闭。