在Lighttpd伺服器中運行Django應用的方法

來源:互聯網
上載者:User
lighttpd (http://www.djangoproject.com/r/lighttpd/) 是一個輕量級的Web伺服器,通常被用來提供靜態頁面的訪問。 它天生支援FastCGI,因此除非你的網站需要一些Apache特有的特性,否則,lighttpd對於靜態和動態網頁面來說都是理想的選擇。

確保 mod_fastcgi 在模組列表中,它需要出現在 mod_rewrite 和 mod_access ,但是要在 mod_accesslog 之前。

將下面的內容添加到你的lighttpd的設定檔中:

server.document-root = "/home/user/public_html"fastcgi.server = ( "/mysite.fcgi" => (  "main" => (   # Use host / port instead of socket for TCP fastcgi   # "host" => "127.0.0.1",   # "port" => 3033,   "socket" => "/home/user/mysite.sock",   "check-local" => "disable",  ) ),)alias.url = ( "/media/" => "/home/user/django/contrib/admin/media/",)url.rewrite-once = ( "^(/media.*)$" => "$1", "^/favicon\.ico$" => "/media/favicon.ico", "^(/.*)$" => "/mysite.fcgi$1",)

在一個lighttpd進程中運行多個Django網站

lighttpd允許你使用條件配置來為每個網站分別提供設定。 為了支援FastCGI的多網站,只需要在FastCGI的設定檔中,為每個網站分別建立條件配置項:

# If the hostname is 'www.example1.com'...$HTTP["host"] == "www.example1.com" { server.document-root = "/foo/site1" fastcgi.server = (  ... ) ...}# If the hostname is 'www.example2.com'...$HTTP["host"] == "www.example2.com" { server.document-root = "/foo/site2" fastcgi.server = (  ... ) ...}

你也可以通過 fastcgi.server 中指定多個入口,在同一個網站上實現多個Django安裝。 請為每一個安裝指定一個FastCGI主機。

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.