Edit PHP Configuration in WHM cPanel

If you own a website that runs in PHP code, sometimes you would want to change PHP configuration on the server in order to enable some feature, or increase/decrease some setting’s limit. For example, you receive this message while running a PHP code on your web server:

Allowed memory size of xxxx bytes exhausted (tried to allocate xxxx bytes) in /home/abc/public_html/abc/abc.php

It means that memory is not enough for the PHP file to execute on the server. So you need to increase memory allocation in PHP. Sometimes, this issue can be fix by modify some PHP file, but that is a temporary solution. To permanently fix the issue on a server, you need to modify php.ini.
Note: If you don’t have access to WHM or SSH (usually on shared hosting), you should ask your hosting if you can change PHP configuration.

This article describes step-by-step how to modify PHP configuration in WHM control panel.

Watch on YouTube

Step-by-step to edit PHP configuration in WHM cPanel

  1. Login to WHM control panel.
    The URL usually be your web server IP address and port number, e.g. https://x.x.x.x:2087. This information can be obtained from your hosting support.
    WHM - Login
  2. After you logged in, scroll down to Service Configuration section on the left menu and click PHP Configuration Editor.
    WHM - Select PHP Configuration Editor
  3. On PHP Configuration Editor, you can edit PHP configurations. The common configurations are:
    • file_uploads
      Whether or not to allow HTTP file uploads.
    • memory_limit
      This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.
    • max_execution_time
      This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30.
    • upload_max_filesize
      The maximum size of an uploaded file.

    In this example, I’m going to change memory_limit from 32MB to 64MB.
    WHM - Edit PHP Configuration

  4. Then, scroll down to bottom of the page and click Save.
    WHM - Save PHP Configuration
  5. PHP configuration is now changed.
    WHM - php.ini has been written

Leave a Reply