Home / Configs / Servers / php.ini settings

php.ini settings: upload size, memory limit and error display

Set the PHP values most sites need: upload size, memory, run time, errors, time zone and OPcache.

For PHP 8.x on Linux with PHP-FPM or Apache. Paths differ on Windows (XAMPP uses C:\xampp\php\php.ini).

Most PHP problems with large uploads, slow scripts or hidden errors come down to a few php.ini values. Set them here, save the result as a small override file, and restart PHP.

Create your config file

Type your own values. The file below updates as you type, and nothing you type leaves your browser.

For example 8M, 64M or 1G
For example UTC, Asia/Kolkata or America/New_York

/etc/php/8.3/fpm/conf.d/99-custom.ini
; Values for uploads, memory and run time
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
max_execution_time = 60
date.timezone = UTC

; Production: hide errors from visitors, keep them in the log
display_errors = Off
log_errors = On

opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000

How this setup works

Diagram: php.ini, then PHP restarts, then Your site
php.ini (your settings) → PHP restarts (reads them) → Your site (new limits apply)

Step-by-step setup

  1. Find the folder PHP reads extra files from: run php --ini and look at "Scan for additional .ini files". On Ubuntu with PHP-FPM it is /etc/php/8.3/fpm/conf.d/.
  2. Save the settings above as 99-custom.ini in that folder. The 99 makes it load last, so it wins.
  3. Restart PHP: sudo systemctl restart php8.3-fpm (use your version), or restart Apache for mod_php.
  4. Check the new values: create a file with <?php phpinfo();, open it, search for upload_max_filesize, then delete the file.
  5. For large uploads also raise client_max_body_size in nginx to the same size.

What the important lines mean

Common errors and how to fix them

The uploaded file exceeds the upload_max_filesize directive
The file is bigger than upload_max_filesize. Raise it and post_max_size, restart PHP, and check the web server limit as well.
413 Request Entity Too Large
This comes from nginx, not PHP. Raise client_max_body_size in the server block.
Allowed memory size of … bytes exhausted
A script needs more than memory_limit. Raise the limit a little, or fix the script that uses too much, such as a huge query.
Maximum execution time of 60 seconds exceeded
The script ran too long. Raise max_execution_time for that job, or move long work to a background task.
My changes do not apply
PHP was not restarted, or you edited the wrong php.ini. The command line and PHP-FPM use different files. Check php --ini for CLI and phpinfo() for the web.

Frequently asked questions

Where is php.ini?
Run php --ini for the command line. For the web server, open a phpinfo() page and look at "Loaded Configuration File". CLI and web can use different files.
Why do I need to change post_max_size too?
A file upload is part of the whole POST request. If post_max_size is smaller than the file, the upload fails even when upload_max_filesize is large.
Is it safe to display errors?
Only on your own computer. On a live site keep display_errors off and read the log instead.

Written for: PHP 8.1 to 8.4 · Updated 2026-10-11

Fix a problem with this setup

More server configs

See all 41 config generators