请求实体太大 PHP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3718571/
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
Request Entity Too Large PHP
提问by gautamlakum
In one of my CakePHP site, I got this error.
在我的一个 CakePHP 站点中,我收到了这个错误。
Request Entity Too Large
请求的实体太大
I don't know what is the problem. I think the data that I am posting through form is too large. I searched this in search engine and got that I will have to increase post_max_size
. Be default I think it is set to 8M.
我不知道是什么问题。我认为我通过表单发布的数据太大。我在搜索引擎中搜索了这个,发现我必须增加post_max_size
。默认我认为它设置为8M。
But don't know how to increase post_max_size
in CakePHP and what to do for it?
但是不知道post_max_size
在CakePHP 中如何增加以及为它做些什么?
Thanks.
谢谢。
回答by Gordon
post_max_size
and upload_max_filesize
are PHP.ini settings. You can set them either directly in PHP.ini or via ini_set
. I don't know if this can be set with some Cake-internal tools as well.
post_max_size
并且upload_max_filesize
是 PHP.ini 设置。您可以直接在 PHP.ini 中或通过ini_set
. 我不知道这是否也可以用一些 Cake 内部工具来设置。
However, the error could also be caused by a set limit of the RequestBodyLength in Apache(assuming you are running under Apache).
但是,该错误也可能是由Apache 中 RequestBodyLength的设置限制引起的(假设您在 Apache 下运行)。
回答by duskstriker
I tried all of these answers and the only thing that worked for me was to tune up the SSL Buffer Size. You can set this by...
我尝试了所有这些答案,唯一对我有用的是调整 SSL 缓冲区大小。您可以通过...
<Directory /my/blah/blah>
...
# Set this to something big big...
SSLRenegBufferSize 10486000
...
</Directory>
...and then just restart Apache to take effect. (Found this at: http://forum.joomla.org/viewtopic.php?p=2085574)
...然后只需重新启动 Apache 即可生效。(在:http: //forum.joomla.org/viewtopic.php?p=2085574找到这个)
回答by Gonfi den Tschal
Another possible cause for the "413 request entity too large" error is mod-security. That was the cause for me.
“413 请求实体太大”错误的另一个可能原因是 mod-security。这就是我的原因。
Looking into the site's Apache error log said:
查看该站点的 Apache 错误日志说:
ModSecurity: Request body no files data length is larger than the configured limit (131072).. Deny with code (413)
ModSecurity:请求正文没有文件数据长度大于配置的限制(131072)..拒绝代码(413)
On my Ubuntu 14.04 the config file is here but this really depends on the system:
在我的 Ubuntu 14.04 上,配置文件在这里,但这实际上取决于系统:
/etc/modsecurity/modsecurity.conf
/etc/modsecurity/modsecurity.conf
There is the default value for SecRequestBodyNoFilesLimit(and possibly also SecRequestBodyInMemoryLimit).
SecRequestBodyNoFilesLimit有默认值(可能还有SecRequestBodyInMemoryLimit)。
回答by Lukas Lukac
Definitely not CakePHP problem but here are the two settings you need to set in order to upload files properly:
绝对不是 CakePHP 的问题,但为了正确上传文件,您需要设置以下两个设置:
vim /etc/php5/php.ini (or wherever the .ini is located)
And set:
并设置:
post_max_size="200M"
upload_max_filesize="200M"
Now the tricky part in case you are using HTTPS! you also need to configure one SSL.
现在是棘手的部分,以防您使用 HTTPS!您还需要配置一个 SSL。
vim /etc/apache2/sites-available/<whatever>-443.conf
And set the SSLRenegBufferSize
并设置 SSLRenegBufferSize
<Directory /appdata/www/<whatever>/web>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
SSLRenegBufferSize 201048600
</Directory>
回答by Travis Leleu
I think you need to set that in the PHP config file, php.ini. If you have a VPS / root level access, just up the size on that. If you don't (shared hosting), you can modify the php ini parameters at runtime. Note that ini_set() won't work here, because the PHP settings are loaded too late (after the file has been uploaded, the PHP script begins execution).
我认为您需要在 PHP 配置文件 php.ini 中进行设置。如果你有 VPS / root 级别的访问权限,只需增加它的大小。如果你没有(共享主机),你可以在运行时修改 php ini 参数。请注意 ini_set() 在这里不起作用,因为 PHP 设置加载太晚(在文件上传后,PHP 脚本开始执行)。
You'll need to include the following in your htaccess file (on shared hosting):
您需要在 htaccess 文件中包含以下内容(在共享主机上):
php_value post_max_size 104857600
It's possible this won't work. Some googling around made it seem as though some shared hosts will lock down this setting, making it not over-rideable in htaccess (just in main server config). If that's the case, you'll need to move hosts.
这可能行不通。一些谷歌搜索使它看起来好像某些共享主机会锁定此设置,使其在 htaccess 中不会被覆盖(仅在主服务器配置中)。如果是这种情况,您需要移动主机。
回答by Leo
Sometimes on shared hosting you can add your own php.ini file - just copy the relevant bits out of any default file (or google for one).
有时在共享主机上,您可以添加自己的 php.ini 文件 - 只需从任何默认文件(或谷歌)中复制相关位。
It's not an error I've seen before - it may as Gordon says, be Apache.
这不是我以前见过的错误 - 正如戈登所说,可能是 Apache。
Don't be afraid to ask the hosting support team - I've always found them to be very helpful (I think they must get lonely), and often they will make config changes for you.
不要害怕询问托管支持团队 - 我一直发现他们非常有帮助(我认为他们一定会感到孤独),而且他们通常会为您更改配置。
It certainly isn't a CakePHP problem.
这当然不是 CakePHP 的问题。