Changing PHP limits such as memory_limit and upload_max_filesize in cPanel

Print
  • 0

"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

  1. In cPanel, under Software, open Select PHP Version.
  2. Switch to the Options tab to see each directive and its current value.
  3. Click a value and pick a new one from the list. It is saved straight away.

Option B: MultiPHP INI Editor

  1. In cPanel, under Software, open MultiPHP INI Editor.
  2. On the Basic Mode tab, choose the domain (or location) whose settings you want to change.
  3. Adjust the values and click Apply or Save, whichever your cPanel version shows.
  4. 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

DirectiveControlsChange it when
memory_limitThe most memory one script may useYou see "Allowed memory size exhausted"
upload_max_filesizeThe largest single file that can be uploadedA theme, large image or archive will not upload
post_max_sizeThe total size of data a form can sendTogether with upload_max_filesize; keep it equal or larger
max_execution_timeHow many seconds a script may runLong imports or exports get cut off
max_input_timeTime allowed to receive a request's dataSlow uploads of big files fail
max_input_varsHow many fields one request may carryA large menu or settings page does not save completely
display_errorsWhether errors are printed on the pageOnly briefly while debugging; keep it off on a live site
session.gc_maxlifetimeHow long, in seconds, session data is keptUsers get logged out too soon

Pitfalls

  • Going overboard. A huge memory_limit does 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_size below upload_max_filesize. Uploads then fail even though the file limit looks big enough.
  • Showing errors to visitors. Leaving display_errors on 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

  1. In File Manager, inside your site's folder (for example public_html), create a file with a hard-to-guess name such as test-php-7391.php containing:
    <?php phpinfo();
  2. Open https://yourdomain.md/test-php-7391.php in your browser and look for the directive under Local Value.
  3. Delete the file as soon as you are done. The phpinfo page reveals server details that should not stay public.

Related articles

Was this answer helpful?