[筆記] 解決 apache mod_fcgid: HTTP request length 136000 (so far) exceeds MaxRequestLen (131072)

logo-Ubuntu
上次寫了一篇

Ubuntu 10.10 (Maverick) 架設 Nginx + PHP FastCGI,不過在 PHP 上傳檔案部份發現了問題,打開 /var/log/apache2/error.log 發現底下錯誤訊息:

mod_fcgid: HTTP request length 136000 (so far) exceeds MaxRequestLen (131072) 上網找了一下是 fcgid.conf 設定錯誤,解決方式非常簡單,只要打開 /etc/apache2/mods-available/fcgid.conf,將底下內容


  AddHandler    fcgid-script .fcgi
  FcgidConnectTimeout 20
取代成

  AddHandler    fcgid-script .fcgi
  FcgidConnectTimeout 20
  # to get around upload errors when uploading images increase the MaxRequestLen size to 15MB
  MaxRequestLen 15728640
如果檔案上傳時間不夠,又會出現底下錯誤
mod_fcgid: read data timeout in 40 seconds
Premature end of script headers: index.php
所以我們將設定檔再改成底下就可以了

  AddHandler    fcgid-script .fcgi

  # fix for:   mod_fcgid: read data timeout in 40 seconds
  IdleTimeout 3600
  DefaultMinClassProcessCount 100
  FcgidConnectTimeout 120
  IPCCommTimeout 400

  # to get around upload errors when uploading images increase the MaxRequestLen size to 15MB
  MaxRequestLen 15728640
最後附上個人 fcgid.conf 設定檔給大家參考

  AddHandler    fcgid-script .fcgi .php
  FcgidConnectTimeout 20
  FcgidIPCDir /var/lib/apache2/fcgid/sock
  IdleTimeout 3600
  ProcessLifeTime 7200
  MaxProcessCount 1000
  DefaultMinClassProcessCount 3
  DefaultMaxClassProcessCount 100
  IPCConnectTimeout 8
  IPCCommTimeout 360
  BusyTimeout 300
  FcgidWrapper /usr/bin/php5-cgi .php
  MaxRequestLen 15728640
參考網站:

[fix] mod_fcgid: HTTP request length xyz (so far) exceeds MaxRequestLen (131072)


See also