Skip to main content
To increase the PHP upload size, edit the PHP-FPM php.ini (on Ubuntu 24.04: /etc/php/8.3/fpm/php.ini) and set upload_max_filesize = 64M, post_max_size = 72M and memory_limit = 256M. Then allow the same size in Nginx with client_max_body_size 64M;. Restart PHP-FPM with sudo systemctl restart php8.3-fpm and reload Nginx. PHP’s defaults are 2 MB uploads and 8 MB posts; Nginx’s is 1 MB.

Before you start

  • Use a user with sudo. If you are root, leave out sudo.
  • An upload passes three limits. The smallest one wins:
    1. The web server: Nginx client_max_body_size (default 1 MB), Apache LimitRequestBody (default 1 GiB).
    2. PHP: upload_max_filesize (default 2 MB) and post_max_size (default 8 MB).
    3. Your app, such as a WordPress plugin or a form library.

Which php.ini do I edit?

PHP for the web and PHP on the command line read different files. php --ini shows only the command-line file, so use this table:

How to raise the PHP limits

1

Edit php.ini

Find and change these lines (press Ctrl+W in nano to search):
post_max_size must be larger than upload_max_filesize, because a form post carries the file plus other fields. memory_limit should be larger than post_max_size.
2

Restart PHP

How to raise the web server limit

Add client_max_body_size inside the site’s server { } block (or in http { } in /etc/nginx/nginx.conf for all sites):

How to set limits for one site only

Create .user.ini in the site’s web root:
PHP-FPM reads it without a restart, but caches it for up to 5 minutes (user_ini.cache_ttl = 300).
upload_max_filesize and post_max_size cannot be changed with ini_set() inside PHP code. Use one of the methods above.

How to check it worked

Create a temporary check file in the web root:
Expected output:
In WordPress, Media > Add New shows the new “Maximum upload file size”.

Frequently asked questions

I get “413 Request Entity Too Large”. Which limit is it?

That comes from Nginx: raise client_max_body_size. The Nginx error log shows client intended to send too large body: … bytes.

WordPress says “The uploaded file exceeds the upload_max_filesize directive in php.ini”. I changed it. Why?

You edited the command-line php.ini or did not restart PHP-FPM. Edit the fpm/php.ini for the PHP version your site uses and restart that version’s service. With several versions installed, see multiple PHP versions.

What memory_limit should I use?

128M is PHP’s default and fine for most sites; 256M suits WordPress with page builders or WooCommerce. Every PHP worker can use up to this amount, so very high values on a small VPS can cause out-of-memory kills.

Large uploads time out. What else should I raise?

Raise max_execution_time in PHP and, for slow PHP responses behind Nginx, fastcgi_read_timeout (default 60 seconds) in the location ~ \.php$ block.

VPS and dedicated server guides

Every server guide in one place.

Install WordPress

Where upload limits matter most.

Install a LEMP stack

Nginx with PHP-FPM.

Multiple PHP versions

One php.ini per version.

Check memory usage

Size memory_limit safely.

Checked against the official PHP core ini directives, PHP .user.ini documentation, nginx core module and Apache core directives on 4 November 2026; php.ini, .user.ini and pool overrides, the limits.php check and the Nginx 413 error tested on Ubuntu 24.04 LTS (Nginx 1.24.0, PHP-FPM 8.3.6). Commands can differ on other distributions or releases.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026