Sometimes when I install a new web server with nginx and php-fpm I run into the problem where my file upload limit is set to 2 MB or less.
This post is to remind me of all the settings that need to be changed to allow uploading files larger than 2 MB.
In PHP there are two settings in
php.ini that need to be changed:
upload_max_filesizesets the maximum size of an uploaded file. It defaults to
post_max_sizesets the maximum size of POST data sent from the browser. Due to encoding, the actual limit of uploaded data will be a bit smaller than this. It can be set to 0 to disable the limit.
There’s also a well-hidden setting in nginx that affects file uploads, that isn’t in any of the sample configuration files and is almost never mentioned anywhere. It also needs to be set.
1m. It sets the limit on the size of the request body that can be uploaded, and can be set to 0 to disable it.
So, to finish up, I will decide how large I want the limit of uploaded files to be, and set these limits as in the examples here:
post_max_size = 0 upload_max_filesize = 128M
nginx.conf, or in an included file: