2013-03-19 50 views
1

我想用Django配置Lighttpd以顯示localhost:3033基本的「hello-world」Django網站(由$ django-admin startproject hellodjango創建)。我遵循documentation,但我無法讓我的網站正常工作。去localhost之後:3033沒有任何反應,我看到的唯一信息是「等待conncetion」的消息。Lighttpd + Django配置 - 「等待連接」

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。

回答

0

您的服務器由於某種原因停止。調試一個可能的方式設置守護進程= 「假」 在這裏:

runfastcgi(方法= 「prefork的」 守護進程= 「真」,主持人= 「127.0.0.1」,端口= 「3033」)

這可能會幫助您瞭解正在發生的情況以及服務器關閉的原因。

0

我試過做你剛做的事。 我發現,使這項工作(我認爲)的另一件事是確保:

  • .fcgi文件具有可執行每個人的權利。
  • 日誌文件夾也必須具有權限。

我所看到的只是項目文件夾的文件列表視圖。 這是你得到什麼? 此外,它不能通過www.helloDjango.com網址爲我工作。

請讓我知道你是否得到相同的結果。 我也發現,獲得一個基本的問候世界的頁面是非常困難和困惑。