Soft2Hosting

Debugging PHP Errors in cPanel Shared Hosting: Error Logs, display_errors & 500 Fixes

Encountering a blank white screen or a generic "HTTP 500 Internal Server Error" when browsing a WordPress website, custom PHP portal, or ecommerce catalog on shared hosting is a common sysadmin frustration. Because production web servers suppress detailed error traces to prevent security disclosure to public visitors, diagnosing the underlying cause requires inspecting server logs. Knowing how to locate, read, and interpret error logs in cPanel allows webmasters to resolve fatal runtime exceptions in minutes.

Understanding PHP Error Reporting Levels

PHP categorizes operational runtime issues into distinct severity levels:

  • Fatal Errors (E_ERROR): Critical issues that immediately halt script execution, such as calling an undefined function, exceeding memory limits, or requiring a non-existent file. These invariably trigger an HTTP 500 response.
  • Warnings (E_WARNING): Non-fatal errors where script execution continues, such as passing invalid parameter types to built-in functions.
  • Notices (E_NOTICE): Informational messages indicating minor syntax oversights, such as accessing an uninitialized array key or variable.
  • Parse Errors (E_PARSE): Syntax mistakes in PHP code (missing semicolons or mismatched brackets) that prevent compilation.

Step 1: Locating Error Logs via cPanel File Manager

When a PHP script encounters an unhandled fatal error on cPanel shared hosting, the PHP runtime appends a detailed diagnostic trace to a local log file named error_log located in the directory where the failing script executed.

To inspect your script error log:

  1. Log in to your cPanel dashboard.
  2. Open the File Manager in the Files section.
  3. Navigate to your website's document root (typically public_html). If the error occurred inside a specific subfolder (such as wp-content/plugins/your-plugin/), look inside that directory as well.
  4. Locate the file named error_log, right-click, and select View or Edit.

A typical fatal error log entry contains timestamps, error severity, an explanatory message, and the exact filename and line number responsible for the crash:

[02-Oct-2026 14:15:22 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function curl_init() in /home/user/public_html/api.php:45
Stack trace:
#0 /home/user/public_html/index.php(12): fetch_api_data()
#1 {main}
  thrown in /home/user/public_html/api.php on line 45

Step 2: Checking the cPanel Errors Interface

In addition to local PHP log files, cPanel maintains a centralized web server error log viewer:

  1. In the cPanel dashboard, scroll to the Metrics section and click on Errors.
  2. This screen displays the last 300 entries from the web server error log, including .htaccess syntax errors, missing file 404s, and permission lockouts.

If your website returns an HTTP 500 error but the local error_log file is empty, the issue is almost certainly an invalid directive inside your .htaccess file. The cPanel Errors log will display the exact offending line in .htaccess.

Step 3: Managing PHP Error Directives in MultiPHP INI Editor

On production websites, PHP should log errors to disk while hiding them from browser visitors. During staging or troubleshooting, however, enabling error logging options is often necessary.

To configure error behavior in cPanel:

  1. Navigate to Software > MultiPHP INI Editor.
  2. Select your target domain from the dropdown.
  3. Review the core error directives:
    • display_errors: Set to Disabled on production sites to prevent visitors from viewing file paths and database queries. Set to Enabled temporarily when debugging a staging instance.
    • log_errors: Always set to Enabled to guarantee errors are captured in error_log.
    • error_reporting: Set to E_ALL & ~E_DEPRECATED & ~E_STRICT to capture meaningful issues without filling logs with minor notices.
    • memory_limit: If you see "Allowed memory size of X bytes exhausted" in your logs, increase this limit to 256M or 512M.
  4. Click Apply to save the changes.

Resolving ModSecurity WAF Triggers and .htaccess Collisions

Sometimes a web application returns an HTTP 403 Forbidden or HTTP 500 Internal Server Error even when PHP runtime code is completely syntax-free. On cPanel shared hosting servers, the Apache web server runs the ModSecurity Web Application Firewall (WAF) to block malicious SQL injection strings and suspicious POST payloads. If a WordPress plugin form or AJAX request contains encoded parameters that trigger a generic WAF rule, ModSecurity terminates the connection before PHP executes.

To diagnose ModSecurity collisions, check the cPanel Errors log or the ModSecurity interface. If an administrative action or legitimate form submission is flagged falsely, you can pinpoint the specific ModSecurity Rule ID in the error log and temporarily disable that individual rule for the affected domain inside cPanel without compromising server-wide firewall protections. Additionally, ensure that your .htaccess file contains valid rewrite directives; misspelled Apache modules or conflicting redirect loops immediately cause the web server to throw a 500 error.

Common PHP Errors and Quick Resolutions

  • Memory Exhaustion: Fatal error: Allowed memory size of 134217728 bytes exhausted. Resolution: Increase memory_limit in MultiPHP INI Editor.
  • Execution Timeout: Fatal error: Maximum execution time of 30 seconds exceeded. Resolution: Increase max_execution_time to 60 or 120 seconds.
  • Missing PHP Extension: Call to undefined function mb_detect_encoding(). Resolution: In cPanel's Select PHP Version or MultiPHP Manager, enable required extensions like mbstring, curl, or gd.
  • File Permission Issues: Scripts returning HTTP 403 or 500 due to permissions. Shared hosting suPHP/FastCGI requires folders to be 755 and PHP files to be 644. Never set permissions to 777.

Soft2Hosting provides shared web hosting accounts equipped with full cPanel administration, automated backups, and PHP version management, giving small businesses the tools to troubleshoot and maintain websites reliably.

Discover plan features on Soft2Hosting Shared Web Hosting.


Sources