Python

共享主機上帶有 FastCGI 的 CherryPy(或其他 Python 框架)

  • November 12, 2009

我正在嘗試在 Apache 上使用 FastCGI(實際上是 fcgid)配置 Python 迷你框架 CherryPy。我在共享主機上,所以我無法訪問 httpd.conf,只能訪問 htaccess。我按照這些教程無濟於事:

  • tools.cherrypy.org/wiki/FastCGIWSGI
  • tools.cherrypy.org/wiki/BluehostDeployment

我不斷收到 500 個錯誤,Apache 日誌顯示“腳本頭過早結束”。我已經嘗試了一切(權限/shebangs/full-paths/deamonized/not-daimonized)。我知道 Apache 正在正確執行我的 .fcgi,因為我能夠從 python 列印到錯誤日誌,但僅此而已。以前有沒有人在共享主機上成功安裝過 CherryPy 或任何其他框架?您的幫助將不勝感激。謝謝。

我在 Server Fault 和 Stack Overflow 上都問過這個問題。我已經解決了這個問題,並在 Stack Overflow 上發布了解決方案:

https://stackoverflow.com/questions/1665742/cherrypy-or-other-python-framework-with-fastcgi-on-shared-host

謝謝。

這是一個非常常見的 apache 錯誤,請參閱 http://httpd.apache.org/docs/1.3/misc/FAQ-F.html#premature-script-headers

如果您的 fcgi 很可能按照您所說的那樣執行,那麼它會因某種未擷取的異常而突然死亡,並且輸出無法正確生成。

我會遵循該連結的建議,特別是嘗試生成輸出(將 apache 排除在等式之外)。

引用自:https://serverfault.com/questions/80836