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 areroot, leave outsudo. - An upload passes three limits. The smallest one wins:
- The web server: Nginx
client_max_body_size(default 1 MB), ApacheLimitRequestBody(default 1 GiB). - PHP:
upload_max_filesize(default 2 MB) andpost_max_size(default 8 MB). - Your app, such as a WordPress plugin or a form library.
- The web server: Nginx
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
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
- Ubuntu / Debian (PHP-FPM)
- Apache mod_php
- AlmaLinux / Rocky
How to raise the web server limit
- Nginx
- Apache
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
- .user.ini (PHP-FPM)
- PHP-FPM pool
- .htaccess (Apache mod_php)
Create PHP-FPM reads it without a restart, but caches it for up to 5 minutes (
.user.ini in the site’s web root: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:Frequently asked questions
I get “413 Request Entity Too Large”. Which limit is it?
That comes from Nginx: raiseclient_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-linephp.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?
Raisemax_execution_time in PHP and, for slow PHP responses behind Nginx, fastcgi_read_timeout (default 60 seconds) in the location ~ \.php$ block.
Related guides
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:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026