cyprich.com

By

Increase Upload Size for PHP in NGINX

The default upload size for PHP is 2M and NGINX also has a default of 1M. This needs to be increased for it to be useful for typical web applications.

You can increase the PHP file upload size limits by editing the following in php.ini:

upload_max_filesize = 100M post_max_size = 100M

I also increase the timeouts to for PHP to keep running while downloading large files.

max_execution_time = 3600
max_input_time = 3600

After editing this, you won’t be able to upload large files until you edit /etc/nginx/nginx.conf:

http {
# affects all server blocks
client_max_body_size 100M;
}

server {
# affects only the server block its defined in
client_max_body_size 100M;
}

Restart the nginx server after the changes are made. Then you can upload large files using a PHP application.

Leave a Reply

Your email address will not be published. Required fields are marked *