Executive Summary
PHP applications on shared and cloud hosting environments are frequently constrained by server-level limits on memory usage, maximum execution time, and file upload size. These limits surface as fatal errors, 504 gateway timeouts, or silent upload failures. This article explains how to identify which directive is being hit, how to adjust limits via cPanel's MultiPHP INI Editor or .htaccess directives, and when to escalate to the hosting team for a server-level configuration change.
PHP resource limits control how much memory, CPU time, and upload bandwidth a single PHP request can consume. When your application exceeds one of these limits, the result is typically a fatal error, a blank page, a 504 gateway timeout, or an upload that silently fails. This guide covers the four most common PHP directives involved, how to diagnose which one is causing the problem, and the two primary paths for adjusting them on INNOVATECH GROUP hosting.
Prerequisites
- An active hosting service with INNOVATECH GROUP (shared, cloud, or dedicated)
- Access to cPanel via the portal's Login to cPanel SSO button (navigate to My Services → hosting service → Quick Access → Login to cPanel)
- Familiarity with PHP error messages and basic server log reading
- For dedicated/VPS servers with root access: SSH access and comfort editing configuration files
The Four Key PHP Resource Directives
memory_limit
Controls the maximum amount of RAM a single PHP script can allocate. When exceeded, PHP terminates the script with a fatal error.
Default: Typically 128M or 256M depending on hosting plan.
Symptoms when exceeded:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes)
Common triggers: Large dataset processing, image manipulation with GD or Imagick, importing CSV files, complex WordPress/WooCommerce operations with many plugins active.
max_execution_time
Controls the maximum number of seconds a PHP script can run before the server terminates it. This does not include time spent on system calls, database queries, or sleep operations — only active PHP execution time.
Default: Typically 30 or 60 seconds.
Symptoms when exceeded:
Fatal error: Maximum execution time of 30 seconds exceeded
Common triggers: Large database migrations, bulk email sending, external API calls that block, plugin/theme updates on WordPress, WooCommerce product imports.
upload_max_filesize
Controls the maximum size of a single uploaded file. Uploads larger than this value are rejected silently — PHP does not process the file at all.
Default: Typically 2M to 64M depending on hosting plan.
Symptoms when exceeded: The upload form appears to succeed but no file is received. PHP's $_FILES array will contain an error code (UPLOAD_ERR_INI_SIZE, value 1).
post_max_size
Controls the maximum size of the entire POST request body, which includes all uploaded files plus form data. This value must be equal to or larger than upload_max_filesize.
Default: Typically 8M to 128M depending on hosting plan.
Symptoms when exceeded: The entire $_POST and $_FILES arrays are empty — PHP discards the request body entirely. This can appear as a blank form submission or a "token mismatch" / CSRF error in frameworks like Laravel.
Step 1: Identify Which Limit Is Being Hit
Check PHP Error Logs
The fastest way to identify a resource limit issue is to read the PHP error log.
Via cPanel:
- Log in to cPanel via the portal SSO button.
- Navigate to Metrics → Errors to view the most recent Apache/PHP error log entries.
- Look for lines containing
Allowed memory size,Maximum execution time, or upload-related errors.
Via SSH (dedicated/VPS only):
# Common log locations
tail -100 /var/log/apache2/error.log
tail -100 /usr/local/apache/logs/error_log
# Or check the domain-specific log
tail -100 ~/logs/yourdomain.co.za-error.log
Check Current PHP Configuration Values
To see the active values for all four directives:
- Create a temporary file named
phpinfo.phpin your site's document root:<?php phpinfo(); - Visit
https://yourdomain.co.za/phpinfo.phpin a browser. - Search for
memory_limit,max_execution_time,upload_max_filesize, andpost_max_size. - Note both the Local Value (active for your site) and the Master Value (server default).
- Delete
phpinfo.phpimmediately after checking — it exposes sensitive server configuration to anyone who can access the URL.
Distinguish Between 504 Gateway Timeout and PHP max_execution_time
A 504 Gateway Timeout error can look similar to a max_execution_time error but has a different cause:
max_execution_time— PHP itself terminates the script. You will see the fatal error in PHP error logs.- 504 Gateway Timeout — the web server (Nginx or Apache reverse proxy) terminates the connection because it waited too long for PHP-FPM to respond. This is a server-level timeout that is separate from PHP's
max_execution_timeand cannot be changed via cPanel or.htaccess.
If you see 504 errors but no PHP fatal error in the logs, the issue is likely the web server's proxy timeout, not PHP's execution time limit. This requires a support ticket.
Step 2: Adjust Limits via cPanel MultiPHP INI Editor
This is the recommended path for shared and cloud hosting plans.
- Log in to cPanel via the portal SSO button.
- Navigate to Software → MultiPHP INI Editor.
- Select Basic Mode for a simplified interface, or Editor Mode if you prefer to edit the raw INI directives.
- In Basic Mode, select the domain you want to configure from the dropdown.
- Locate and adjust the relevant directives:
memory_limit— increase to256Mor512Mas neededmax_execution_time— increase to120or300for long-running operationsupload_max_filesize— increase to64Mor128Mas neededpost_max_size— set equal to or larger thanupload_max_filesize
- Click Apply to save.
Changes take effect immediately for new PHP requests. Existing long-running processes are not affected.
Limits You May Encounter
Hosting plans may impose soft ceilings on these values. If cPanel allows you to enter a value but the change does not take effect (the phpinfo() Local Value remains unchanged), the hosting server has a system-level maximum that overrides your setting. In this case, open a support ticket to request an increase.
Step 3: Alternative — Adjust Limits via .htaccess
If cPanel's MultiPHP INI Editor is unavailable or gives unexpected results, you can set PHP directives via your site's .htaccess file. This works on Apache-based hosting with mod_php or when PHP is running as an Apache module.
Add the following lines to the .htaccess file in your site's document root:
php_value memory_limit 256M
php_value max_execution_time 120
php_value upload_max_filesize 64M
php_value post_max_size 128M
Important caveats:
- The
php_valuedirective only works when PHP is running as an Apache module. On servers using PHP-FPM (increasingly common),.htaccessPHP directives are silently ignored. Use the MultiPHP INI Editor or a customphp.inifile instead. - If you see a 500 Internal Server Error after adding these lines, your server likely uses PHP-FPM. Remove the
php_valuelines and use the cPanel INI editor.
Step 4: Validate the Change
After making adjustments:
- Revisit your
phpinfo.phppage (create it again temporarily if deleted). - Confirm that the Local Value for each directive matches your new setting.
- Test the operation that was previously failing (file upload, long-running import, etc.).
- Delete
phpinfo.phpagain after verification.
Common Failure Modes
| Symptom | Likely Cause | Action |
|---|---|---|
Allowed memory size exhausted persists after increase |
Server-level cap overrides your setting (PHP_INI_SYSTEM context) |
Open a support ticket |
.htaccess causes 500 error |
Server uses PHP-FPM, not mod_php |
Remove php_value lines; use MultiPHP INI Editor |
| Upload appears to work but file is missing | post_max_size is smaller than upload_max_filesize |
Set post_max_size ≥ upload_max_filesize |
504 Gateway Timeout despite high max_execution_time |
Web server proxy timeout (Nginx/Apache), not PHP | Open a support ticket |
| Changes in cPanel INI editor revert after PHP version change | MultiPHP INI settings are per PHP version | Re-apply settings after switching PHP versions |
Security Considerations
- Setting
memory_limitextremely high (e.g.4G) on shared hosting can affect other tenants on the same server. Use the minimum value that resolves the issue. - Very long
max_execution_timevalues (e.g.600) increase the window for resource-exhaustion attacks. Only increase this for specific use cases and consider using background job processing (Laravel queues, WP-Cron, or WP-CLI) for long-running tasks instead. - Never leave a
phpinfo.phpfile accessible in production. It exposes PHP version, loaded extensions, environment variables, and server paths.
When to Contact INNOVATECH GROUP Support
Open a support ticket if:
- Your cPanel INI editor changes are being silently overridden by a server-level maximum
- You are experiencing 504 Gateway Timeout errors that are not caused by PHP's
max_execution_time - You need resource limits raised beyond your hosting plan's soft ceiling
- You have root SSH access on a dedicated server and need guidance on editing the system-wide
php.ini - You are unsure which PHP handler your server uses (Apache module, PHP-FPM, CGI) and which configuration method applies