php 如何避免请求实体太大 413 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18121227/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to avoid Request Entity Too Large 413 error
提问by Chelz Adams
How to avoid this 413 error ?
如何避免这个 413 错误?
Request Entity Too Large
The requested resource /serverpath/reports.php does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
Apache Server at demo3.website_name Port 80
请求的实体太大
请求的资源 /serverpath/reports.php 不允许使用 POST 请求请求数据,或者请求中提供的数据量超过容量限制。
Apache 服务器在 demo3.website_name 端口 80
So, could any one please help to set php.ini and how to set htaccess to allow overwrite status
那么,任何人都可以帮助设置 php.ini 以及如何设置 htaccess 以允许覆盖状态
回答by mzalazar
How to fix it in NGINX? client_max_body_size
如何在 NGINX 中修复它?client_max_body_size
To fix this, you need to increase the value of the client_max_body_size directive. This directive defines the maximum amount of data Nginx will accept in an HTTP request. By default this value is set to 1 megabyte, meaning if you attempt to upload a file larger than 1 megabyte you'll be getting an Error 413: Request entity too large page. You can insert this directive at three levels:
要解决此问题,您需要增加 client_max_body_size 指令的值。该指令定义了 Nginx 将在 HTTP 请求中接受的最大数据量。默认情况下,此值设置为 1 兆字节,这意味着如果您尝试上传大于 1 兆字节的文件,您将收到错误 413:请求实体页面太大。您可以在三个级别插入此指令:
In the http block: this will set the directive value for all server and locations in your configurationn
In the server block: this will set the directive value for all locations of one particular server
In the location block: this will set the directive value for one specific location in a particular server
在 http 块中:这将为配置中的所有服务器和位置设置指令值
在服务器块中:这将为一个特定服务器的所有位置设置指令值
在位置块中:这将为特定服务器中的一个特定位置设置指令值
In this example I'm going to insert it in my http block and set it to 500 megabytes:
在本例中,我将把它插入到我的 http 块中并将其设置为 500 兆字节:
http {
client_max_body_size 500M; # allows file uploads up to 500 megabytes
[...]
}
source: http://cnedelcu.blogspot.com.ar/2013/09/nginx-error-413-request-entity-too-large.html
来源:http: //cnedelcu.blogspot.com.ar/2013/09/nginx-error-413-request-entity-too-large.html
回答by Conrad Lotz
Try to look for the following line in the php.ini
and set it to the size that you require:
尝试在 中查找以下行php.ini
并将其设置为您需要的大小:
post_max_size = 25M
You can then set it in the .htaccess
file:
然后你可以在.htaccess
文件中设置它:
php_value post_max_size 25M
回答by briskola
On Apache 2.4 it is worth looking at the LimitRequestBody
directive as well. It can be configured per vhost and it goes into the <Directory>
section.
在 Apache 2.4 上,该LimitRequestBody
指令也值得一看。它可以针对每个虚拟主机进行配置,并进入该<Directory>
部分。
<VirtualHost *:80>
[...]
<Directory "/var/www/public_html">
[...]
LimitRequestBody 33554432
</Directory>
</VirtualHost>
The size value is in bytes. This finally solved it for me when I tried both the php.ini
max size directives and was still getting errors.
大小值以字节为单位。当我尝试了php.ini
最大大小指令但仍然出现错误时,这最终为我解决了这个问题。
回答by Bart Friederichs
php.ini
has a setting called post_max_size
, which is set to 8M by default (on Ubuntu at least).
php.ini
有一个名为 的设置post_max_size
,默认情况下设置为 8M(至少在 Ubuntu 上)。
Consider increasing that value if you are posting a lot of data.
如果您要发布大量数据,请考虑增加该值。
回答by brian
Unbeknownst to me, a backslash was being added to a custom font field in a WP Plugin that I had, and another character was being added every time I navigated away from the page. Eventually I had a massive string of //////////s and this resulted in a "request entity too large' error. MY ISP upped the max post and vars = in my .ini but this did not solve the problem. It was solved immediately upon discovery and removal of the massive text string. Hope this helps someone else.
我不知道的是,在我拥有的 WP 插件中的自定义字体字段中添加了一个反斜杠,并且每次我离开页面时都会添加另一个字符。最终我有一大串 /////////s ,这导致了“请求实体太大”错误。我的 ISP 提高了 .ini 中的 max post 和 vars = 但这并没有解决问题。发现并删除大量文本字符串后立即解决了。希望这对其他人有所帮助。