1. 程式人生 > 其它 >上傳檔案報413 Request Entity Too Large錯誤解決辦法

上傳檔案報413 Request Entity Too Large錯誤解決辦法

1、nginx伺服器的解決辦法

修改nginx.conf的值就可以解決了
將以下程式碼貼上到nginx.conf內

 
client_max_body_size 20M;

可以選擇在http{ }中設定:client_max_body_size 20m;
也可以選擇在server{ }中設定:client_max_body_size 20m;
還可以選擇在location{ }中設定:client_max_body_size 20m;
三者有區別
設定到http{}內,控制全域性nginx所有請求報文大小
設定到server{}內,控制該server的所有請求報文大小
設定到location{}內,控制滿足該路由規則的請求報文大小

同時記得修改php.ini內的上傳限制
upload_max_filesize = 20M

注意:如果以上修改完畢後還會出現413錯誤的話 , 可能是域名問題 , 本人遇到過此類情況 , 記錄

2、apache伺服器修改

在apache環境中上傳較大軟體的時候,有時候會出現413錯誤,出現這個錯誤的原因,是因為apache的配置不當造成的,找到apache的配置檔案目錄也就是conf目錄,和這個目錄平行的一個目錄叫conf.d開啟這個conf.d,裡面有一個php.conf

 
目錄內容如下: 
# 
# PHP is an HTML-embedded scripting language which attempts to make it 
# easy for developers to write dynamically generated webpages. 
# 

LoadModule php4_module modules/libphp4.so 

# 
# Cause the PHP interpreter handle files with a .php extension. 
# 

SetOutputFilter PHP 
SetInputFilter PHP 
LimitRequestBody 6550000 

# 
# Add index.php to the list of files that will be served as directory 
# indexes. 
# 
DirectoryIndex index.php 

誤就發生在這個LimitRequestBody配置上,將這個的值改大到超過你的軟體大小就可以了
如果沒有這個配置檔案請將

 
SetOutputFilter PHP 
SetInputFilter PHP 
LimitRequestBody 6550000 

寫到apache的配置檔案裡面即可。

3、IIS伺服器(Windows Server 2003系統IIS6)

先停止IIS Admin Service服務,然後
找到windows\system32\inesrv\下的metabase.xml,開啟,找到ASPMaxRequestEntityAllowed 修改為需要的值,然後重啟IIS Admin Service服務

1、在web服務擴充套件 允許active server pages和在伺服器端的包含文件
2、修改各站點的屬性 主目錄-配置-選項-啟用父路徑
3、使之可以上傳大文件(修改成您想要的大小就可以了,以位元組為單位)
c:\WINDOWS\system32\inetsrv\MetaBase.xml

!企業版的windows2003在第592行
預設的預設定值 AspMaxRequestEntityAllowed="204800" 即200K

將其加兩個0,即改為,現在最大就可以上傳20M了。
AspMaxRequestEntityAllowed="20480000"