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
- 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.
- After you logged in, scroll down to Service Configuration section on the left menu and click PHP Configuration Editor.
- On PHP Configuration Editor, you can edit PHP configurations. The common configurations are:
Whether or not to allow HTTP file uploads.
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.
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.
The maximum size of an uploaded file.
- Then, scroll down to bottom of the page and click Save.
- PHP configuration is now changed.