Increase file upload size on PHP/NGinx server

Here's a quick article on how to configure NGinx and PHP to allow really large uploads.

You might get a HTTP error in WordPress when trying to upload a large photo, or phpMyAdmin might whine you about a file size. Here’s how to lift the file size limit.

PHP config

See where your php.ini file is located:

$ php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/gd.ini,

It should be the Loaded Configuration File in /etc/php5/cli/php.ini. Pop it open and change the following:

upload_max_filesize = 100M
post_max_size = 100M

Next NGinx.

NGinx config

Somewhere in your server block, or in nginx.conf file there should be a http directive, add clinet_max_body_size somewhere in it:

http {
    # [...]
    client_max_body_size 100m;
    # [...]

Note: if really large file, might need to change client_body_timeout parameter to something large, default is 60s.

Then reload both services for the changes to take effect:

$ sudo service nginx reload
$ sudo service php-fpm reload


  • Janmejai says:

    I have tried all this, but still I can’t upload images larger than 80KB. Any hint?

  • Inigo says:

    Thanks, worked as expected.

  • Anonymous says:

    me too, not working i have kept the config in nginx

  • Charles says:

    It is the php-fpm ini file that needs updating not the cli. Edit the /etc/php/7.0/fpm/php.ini for php7, for php5+ just replace 7.0 with 5…

Club-Mate, the beverage →