php 413请求实体太大

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26608606/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:58:19  来源:igfitidea点击:

413 Request Entity Too Large

phplaravelnginx

提问by AhmedShawky

I use nginX/1.6 and laravel when i posted data to server i get this error 413 Request Entity Too Large. i tried many solutions as bellow

当我将数据发布到服务器时,我使用 nginX/1.6 和 laravel,我收到此错误 413 请求实体太大。我尝试了许多解决方案,如下所示

1- set client_max_body_size 100m; in server and location and http in nginx.conf.
2- set upload_max_filesize = 100m in php.ini
3- set post_max_size = 100m in php.ini

After restarting php5-fpm and nginx the problem still not solved

重启php5-fpm和nginx后问题依旧没有解决

回答by Green Lei

Add ‘client_max_body_size xxM' inside the http section in /etc/nginx/nginx.conf, where xx is the size (in megabytes) that you want to allow.

在 /etc/nginx/nginx.conf 的 http 部分中添加“client_max_body_size xxM”,其中 xx 是您要允许的大小(以兆字节为单位)。

http {
      client_max_body_size 20M;         
}

回答by adnan ahmady

I had the same issue but in docker. when I faced this issue, added client_max_body_size 120M;to my Nginx server configuration,

我有同样的问题,但在 docker 中。当我遇到这个问题时,添加client_max_body_size 120M;到我的 Nginx 服务器配置中,

nginx default configuration file path is /etc/nginx/conf.d/default.conf

nginx默认配置文件路径是 /etc/nginx/conf.d/default.conf

server {
    client_max_body_size 120M;
    ...

it resizes max body size to 120 megabytes.

它将最大主体大小调整为 120 兆字节。

after that, I did add these three lines to my PHP docker file

之后,我确实将这三行添加到我的 PHP docker 文件中

RUN echo "max_file_uploads=100" >> /usr/local/etc/php/conf.d/docker-php-ext-max_file_uploads.ini
RUN echo "post_max_size=120M" >> /usr/local/etc/php/conf.d/docker-php-ext-post_max_size.ini
RUN echo "upload_max_filesize=120M" >> /usr/local/etc/php/conf.d/docker-php-ext-upload_max_filesize.ini

since docker PHP image automatically includes all setting files from the path (/usr/local/etc/php/conf.d/) into php.ini file, PHP configuration file will change by these three lines and the issue must disappear

由于 docker PHP 镜像会自动将路径 ( /usr/local/etc/php/conf.d/) 中的所有设置文件包含到 php.ini 文件中,因此 PHP 配置文件将更改为这三行,问题必须消失

回答by Jorge Aires Jr.

I am using Docker and PHP 7.4 and I faced this issue too.

我正在使用 Docker 和 PHP 7.4,我也遇到了这个问题。

Just added a line to the file *.confinside docker/php74/directory.

刚刚在docker/php74/目录中的文件*.conf 中添加了一行。

server {
    client_max_body_size 100M;
    ...
}