Changing PHP limits such as memory_limit and upload_max_filesize in cPanel
Print"Allowed memory size exhausted", an upload that refuses to go through or an import that stops halfway: these usually come down to PHP settings. The values normally live in php.ini, and cPanel lets you change them yourself without touching any system file.
Which tool to use
cPanel offers two places for PHP settings. The right one depends on where your site's PHP version is chosen:
- Select PHP Version (Software section): if the version is picked here, change the values on the Options tab of the same page.
- MultiPHP INI Editor (Software section): for domains whose version is set in MultiPHP Manager.
Not sure which applies? Make the change, then run the check at the end of this article. The value it shows is the one your site really uses.
Option A: Select PHP Version, Options tab
- In cPanel, under Software, open Select PHP Version.
- Switch to the Options tab to see each directive and its current value.
- Click a value and pick a new one from the list. It is saved straight away.
Option B: MultiPHP INI Editor
- In cPanel, under Software, open MultiPHP INI Editor.
- On the Basic Mode tab, choose the domain (or location) whose settings you want to change.
- Adjust the values and click Apply or Save, whichever your cPanel version shows.
- For a directive that is not in the list, go to Editor Mode, pick the same location and add one directive per line, for example:
display_errors = Off log_errors = On
The directives people change most
| Directive | Controls | Change it when |
|---|---|---|
memory_limit | The most memory one script may use | You see "Allowed memory size exhausted" |
upload_max_filesize | The largest single file that can be uploaded | A theme, large image or archive will not upload |
post_max_size | The total size of data a form can send | Together with upload_max_filesize; keep it equal or larger |
max_execution_time | How many seconds a script may run | Long imports or exports get cut off |
max_input_time | Time allowed to receive a request's data | Slow uploads of big files fail |
max_input_vars | How many fields one request may carry | A large menu or settings page does not save completely |
display_errors | Whether errors are printed on the page | Only briefly while debugging; keep it off on a live site |
session.gc_maxlifetime | How long, in seconds, session data is kept | Users get logged out too soon |
Pitfalls
- Going overboard. A huge
memory_limitdoes not create memory, because the account still runs within its plan's resource limits. Raise values step by step until the problem is gone. post_max_sizebelowupload_max_filesize. Uploads then fail even though the file limit looks big enough.- Showing errors to visitors. Leaving
display_errorson can expose paths and other details. Use the error log for debugging instead. - Checking too soon. Some changes take a few minutes to apply. If you still see the old value, wait a little and reload.
Confirming the change took effect
- In File Manager, inside your site's folder (for example
public_html), create a file with a hard-to-guess name such astest-php-7391.phpcontaining:<?php phpinfo();
- Open
https://yourdomain.md/test-php-7391.phpin your browser and look for the directive under Local Value. - Delete the file as soon as you are done. The phpinfo page reveals server details that should not stay public.