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


Club-Mate, the beverage →