简体   繁体   English

PHP AWS Elastic Beanstalk - 不能发布超过 2GB 的文件

[英]PHP AWS Elastic Beanstalk - Cannot post file more than 2GB

I have deployed an application in Elastic Beanstalk, changed some configuration so that I can upload larger files and restart nginx server.我在 Elastic Beanstalk 中部署了一个应用程序,更改了一些配置,以便我可以上传更大的文件并重新启动 nginx 服务器。 When I upload one file less than 2 GB, it is uploaded successfully.当我上传一个小于 2 GB 的文件时,它已成功上传。 However, when I upload a file more than 2 GB, it does not upload successfully.但是,当我上传超过 2 GB 的文件时,它不会成功上传。 Below are the lines that I have added in /etc/nginx/nginx.conf file:以下是我在 /etc/nginx/nginx.conf 文件中添加的行:

client_max_body_size 7500M;
proxy_connect_timeout 1200s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
fastcgi_send_timeout 1200s;
fastcgi_read_timeout 1200s;

Also, I have added config file in.ebextensions and put in the following content:另外,我在.ebextensions 中添加了配置文件并放入以下内容:

files:
    "/etc/php.d/99uploadsize.ini":
        mode: "000644"
        owner: root
        group: root
        content: |
            post_max_size = 5000M
            upload_max_filesize = 5000M
            memory_limit = 5000M
commands:
    remove_old_ini:
        command: "rm -f /etc/php.d/99uploadsize.ini.bak"

and also tried the following content:并且还尝试了以下内容:

files:
    "/etc/nginx/conf.d/proxy.conf":
        mode: "000755"
        owner: root
        group: root
        content: |
            post_max_size = 7500M
            upload_max_filesize = 5000M
            memory_limit = 7500M
            client_max_body_size = 5000M

Here is the phpinfo() snapshot:这是 phpinfo() 快照:

在此处输入图像描述

Where am I going wrong?我哪里错了? Kindly assist me请帮助我

PHP Settings PHP 设置

Your PHP Settings are absolute correct are there is no error is the settings.您的 PHP 设置是绝对正确的,没有错误是设置。

Uploading Error Not PHP上传错误不是 PHP

As per you picture posted the Error Code ie 7 which means根据您发布的图片,错误代码即 7 这意味着

UPLOAD_ERR_CANT_WRITE - 7; UPLOAD_ERR_CANT_WRITE - 7; Failed to write file to disk. 无法将文件写入磁盘。 Introduced in PHP 5.1.0 在 PHP 5.1.0 中引入

It means you uploading code is correct but at the time of writing the file on the system it is failed.这意味着您上传的代码是正确的,但在系统上写入文件时它失败了。

Apache Settings Apache 设置

LimitRequestBody 限制请求体

This directive specifies the number of bytes from 0 (meaning unlimited) to 2147483647 (2GB) that are allowed in a request body.该指令指定请求正文中允许的从 0(表示无限)到 2147483647 (2GB) 的字节数。

The LimitRequestBody directive allows the user to set a limit on the allowed size of an HTTP request message body within the context in which the directive is given (server, per-directory, per-file or per-location). LimitRequestBody 指令允许用户在给出指令的上下文(服务器、每个目录、每个文件或每个位置)内设置 HTTP 请求消息正文的允许大小限制。 If the client request exceeds that limit, the server will return an error response instead of servicing the request.如果客户端请求超过该限制,服务器将返回错误响应而不是为请求提供服务。 The size of a normal request message body will vary greatly depending on the nature of the resource and the methods allowed on that resource.正常请求消息正文的大小将根据资源的性质和该资源允许的方法而有很大差异。 CGI scripts typically use the message body for retrieving form information. CGI 脚本通常使用消息正文来检索表单信息。 Implementations of the PUT method will require a value at least as large as any representation that the server wishes to accept for that resource. PUT 方法的实现将需要一个至少与服务器希望为该资源接受的任何表示一样大的值。

This directive gives the server administrator greater control over abnormal client request behavior, which may be useful for avoiding some forms of denial-of-service attacks.该指令使服务器管理员可以更好地控制异常客户端请求行为,这可能有助于避免某些 forms 的拒绝服务攻击。

Solution:解决方案:

You cannot post/upload the file through PHP more than 2 GB as Apache server will not let it do it.您不能通过 PHP 发布/上传超过 2 GB 的文件,因为 Apache 服务器不会让它这样做。

The Only solution through is that you can zip it and while doing zip split the file less then 2 GB per file and then unzip them, to server which each request.唯一的解决方案是您可以使用 zip 并在执行 zip 时将文件拆分为每个文件小于 2 GB,然后将它们解压缩到每个请求的服务器。

Run the script to unzip the file and do things.运行脚本以解压缩文件并执行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM