In nano, press CTRL + W and search for upload_max_filesize and change the value to 64M (for 64 megabytes). Press CTRL + W again and search for post_max_size and change the value to 64M (for 64 megabytes). You may also need to edit the Nginx configuration file.
By default, Nginx has a limit of 1MB on file uploads. To set file upload size, you can use the client_max_body_size directive, which is part of Nginx's ngx_http_core_module module. This directive can be set in the http, server or location context.
Now that you are editing the file you need to add the line into the server block, like so;
server {
client_max_body_size 8M;
//other lines...
}
If you are hosting multiple sites add it to the http context like so;
http {
client_max_body_size 8M;
//other lines...
}
And also update the upload_max_filesize
in your php.ini file so that you can upload files of the same size.
Once you are done you need to save, this can be done in vi with pressing esc
key and typing :wq
and returning.
Now you need to restart nginx and php to reload the configs. This can be done using the following commands;
sudo service nginx restart
sudo service php5-fpm restart
Or whatever your php service is called.
In case if one is using nginx proxy as a docker container (e.g. jwilder/nginx-proxy), there is the following way to configure client_max_body_size
(or other properties):
/etc/nginx/proxy.conf
with a right value for this property-v /etc/nginx/proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro
Personally found this way rather convenient as there's no need to build a custom container to change configs. I'm not affiliated with jwilder/nginx-proxy
, was just using it in my project, and the way described above helped me. Hope it helps someone else, too.
First Navigate the Path of php.ini
sudo vi /etc/php/7.2/fpm/php.ini
then, next change
upload_max_filesize = 999M
post_max_size = 999M
then ESC-->:wq
Now Lastly Paste this command,
sudo systemctl restart php7.2-fpm.service
you are done.
You can increase client_max_body_size and upload_max_filesize + post_max_size all day long. Without adjusting HTTP timeout it will never work.
//You need to adjust this, and probably on PHP side also. client_body_timeout 2min // 1GB fileupload
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With