A good[ish] website

Web development blog, loads of UI and JavaScript topics

Increase file upload size on PHP/NGINX server

Filed under: Server, WordPress/PHP— Tagged with: nginx, php

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


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

Comments would go here, but the commenting system isn’t ready yet, sorry.

  • © 2022 Antti Hiljá
  • About
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!