江边闲话集

02/29/2008

"Premature end of script headers: dispatch.fcgi"终极解决方案

Filed under: 一技之长 — Tags: , — 张太国 @ 11:56

名字够响亮,当然内容也很响亮。哈哈。

现状:

   当使用Apache(或其他web server,例如lighttpd),以及fastcgi(或cgi)等来部署rails或python等时,经常会出现以下错误:

     Premature end of script headers: dispatch.fcgi

解决方案:

本解决方案是基于Rails+Apache+fastcgi+debian,其他类似。

  • 检查dispatch.fcgi的用户或用户组,以及访问权限,至少定义为755.
  • 检查dispatch.fcgi的第一行的ruby编译器是否正确,很多人开发在windows平台上,而部署则在Linux/Unix平台上,所以将#!C:/ruby.exe改为#  !/usr/bin/ruby。ruby具体在什么位置,输入whereis ruby即可。
  • 不能允许有打印的代码。例如在rails里,坚决不要将p 或puts写到代码里,这样会导致header破坏。其他语言看着办。
  • 如果以上方案均为解决,到dispatch所在的目录下运行 ./dispatch.fcgi看是否正确。如果有什么错误的话,修正即可。

以上提供的4种方案都可以解决这个问题。要是还是不能解决,请将您的case告诉我。

另外,可以参考另一文章:在Debian上部署Rails Apache+fcgi(或FastCgi)

6 Comments

  1. […] "Premature end of script headers: dispatch.fcgi"终极解决方案 […]

    Pingback by 第36个标记 » 在Debian上部署Rails Apache+fcgi(或FastCgi) — 04/30/2008 @ 11:05

  2. […] “Premature end of script headers: dispatch.fcgi”终极解决方案 […]

    Pingback by 第36个标记 » 谈解决方案 — 06/26/2008 @ 15:35

  3. […] “Premature end of script headers: dispatch.fcgi”终极解决方案 […]

    Pingback by 第36个标记 » RMagick 2和ImageMagick不能正确显示图片的解决方案 — 06/26/2008 @ 15:43

  4. This It’s best to participate in a contest for among the finest blogs on the web. I will suggest this web site!

    Comment by michael kors outlet — 09/25/2015 @ 15:44

  5. ray ban sunglasses
    oakley sunglasses wholesale
    michael kors outlet
    Coach Outlet

    Comment by cheap ray ban sunglasses — 03/13/2016 @ 16:26

  6. Perhaps this is one of the most interesting blogs that I have ever seen.

    Comment by http://maruta.be/prinzayut/8 — 06/04/2016 @ 11:54

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress