Mod-Rewrite

trac:“內部伺服器錯誤 (500)”,帶有 mod_fcgid 和 mod_suexec

  • March 10, 2015

我嘗試在具有 shell 訪問權限的共享伺服器上設置 Trac,SW 是 Trac 1.0.1、Python 2.6.6、Apache 2.2.15,帶有 mod_fcgid 和 mod_suexec。

我已經按照我的主機 wiki 的說明進行了設置,https: //uberspace.de/dokuwiki/cool:trac 。唯一的區別是我的 TRAC_ENV 目錄位於子目錄中,而不是直接在我的家中(即 ~/path/to/trac,而不是 ~/trac)。(我在 DocRoot 中將 trac.fcgi 重命名為 foo-trac.fcgi,如下所示。但我也嘗試過重命名為 trac.fcgi。)

如那裡所寫,我已將 trac.fcgi(也嘗試使用 trac.cgi)從 TRAC_ENV/deploy/cgi-bin/ 複製到 $DocRoot/foo/foo-trac.fcgi 並添加

Options +ExecCGI
AddHandler fcgid-script .fcgi   # also tried "AddHandler cgi-script .cgi"
RewriteEngine On
RewriteBase /foo
RewriteRule ^$ foo-trac.fcgi  [L]   # also tried foo-trac.cgi
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) foo-trac.fcgi/$1  [QSA,L]  # also tried foo-trac.cgi

到 $DocRoot/foo/.htaccess。

TRAC_ENV 在 foo-trac.f?cgi 中正確設置(絕對路徑從 / 開始),

但現在,我只得到“500 Internal Server Error”,在我的error_log中我得到

(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
Premature end of script headers: foo-trac.fcgi

(與 fcgi),分別

suexec failure: could not open log file
fopen: Permission denied
Premature end of script headers: foo-trac.cgi

(使用 cgi)。

所有的 .f?cgi 文件,它們的目錄,.egg_cache 目錄(我已經 mkdir’ed 它,不存在並且不是由 trac(或 python)本身創建的),並且日誌目錄是模式 0755。日誌文件是 0644(我已經嘗試過觸摸它們)。

(嗯,Apache 日誌目錄和文件歸 root 所有(組也是)。但我當然不會嘗試自己在那裡寫任何日誌,TRAC_ENV/log/ 和 ~/log/ 是我的,我還嘗試將模式 777 (dir) 分別設置為 666 (trac.log) - 沒有幫助,所以我再次將該模式反轉為 755/644。)

我也已經嘗試/檢查了來自http://encodable.com/internal_server_error/和 /suexec_problems/ 的提示,但沒有任何效果或幫助。

在哪裡搜尋問題的任何提示(似乎是 suexec,但也許是重寫規則;但是/和),如何發現它?或者也許有人直接有解決方案?:)

問候,

分解

嗯,我有答案了。

我必須道歉:這是http://encodable.com/internal_server_error/的提示之一,儘管 - 我天真地相信,行尾一定是正確的(Unix 風格,而不是Windows CR/LF 結尾),因為我只使用 Linux。

而且我沒想到我會從 trac 項目中得到損壞的文件……但事實就是如此,這要感謝我的主機 uberspace.de 的支持,他找到了它。:)

所以,一個簡單dos2unix trag.fcgi的解決了這個問題 - 但在整個 TRAC_ENV 目錄和庫(在我的情況下是 ~/lib/python2.6/)中有很多 CRLF 結尾文件,所以我推薦類似的東西

for file in $( find $TRAC_ENV $LIB_DIR -type f | xargs file | grep -i text | grep CRLF | cut -d\: -f1 ); 
do 
  dos2unix $file
done

你應該又快樂了!;)

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