I have deployed an application in Elastic Beanstalk, changed some configuration so that I can upload larger files and restart nginx server. When I upload one file less than 2 GB, it is uploaded successfully. However, when I upload a file more than 2 GB, it does not upload successfully. Below are the lines that I have added in /etc/nginx/nginx.conf file:
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:
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:
Where am I going wrong? Kindly assist me
Advertisement
Answer
PHP Settings
Your PHP Settings are absolute correct are there is no error is the settings.
Uploading Error Not PHP
As per you picture posted the Error Code i.e. 7 which means
UPLOAD_ERR_CANT_WRITE – 7; Failed to write file to disk. Introduced in 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
This directive specifies the number of bytes from 0 (meaning unlimited) to 2147483647 (2GB) that are allowed in a request body.
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). 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. 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.
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.
Solution:
You cannot post/upload the file through PHP more than 2 GB as Apache server will not let it do it.
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.
Run the script to unzip the file and do things.