How to Enable Error Logging in cPanel (PHP Errors & Server Logs)

Overview

When something breaks on your website, PHP errors are usually the first place to look. But by default, most hosting environments suppress these errors on the front end — which is correct for a live site, but makes debugging a nightmare if you don’t have logging enabled. The cPanel error log is your fastest way to find out what PHP, your application, or the server itself is complaining about.

This article covers how to enable PHP error logging through cPanel’s built-in tools, via a php.ini file, and directly through your .htaccess file. It also covers where your error logs actually live and how to read them without going cross-eyed.

This applies to shared hosting accounts running cPanel (version 106+), but the PHP configuration steps also apply to VPS environments where cPanel/WHM is installed. If you’re on our Shared Hosting plans, this is the most common method you’ll use.

Prerequisites

  • Active cPanel login credentials for your hosting account
  • At least one domain or subdomain set up under your account
  • FTP/SFTP access or access to cPanel’s File Manager (for editing config files)
  • Basic familiarity with file paths like /home/username/public_html/
  • If you’re editing php.ini manually, you’ll need to know which PHP version your account is using (check under Software > MultiPHP Manager)

Step-by-Step Instructions

Method 1: Enable Error Logging via cPanel’s MultiPHP INI Editor

This is the easiest method for shared hosting users and doesn’t require touching any files manually.

  1. Log in to cPanel.
  2. Scroll to the Software section and click MultiPHP INI Editor.
  3. Under the Editor Mode tab, select the domain you want to configure from the dropdown.
  4. Find the following directives and set them as shown:
    • error_reporting — set to E_ALL
    • log_errors — set to On
    • display_errors — set to Off (more on why below)
    • error_log — set to a path like /home/yourusername/logs/php_errors.log
  5. Click Apply.

📝 Note: Keep display_errors set to Off on any live site. Turning it on outputs raw PHP errors directly to your web pages, which can expose file paths, database credentials, and internal logic to anyone visiting your site. Log to file — don’t display.

Method 2: Configure Logging in a Custom php.ini File

If you need per-directory control, or the INI Editor isn’t available on your plan, you can drop a php.ini file directly into the directory you want to monitor.

  1. Open cPanel’s File Manager and navigate to /home/yourusername/public_html/ (or a subdirectory you’re debugging).
  2. Create a new file named php.ini in that directory.
  3. Add the following:

    error_reporting = E_ALL
    log_errors = On
    display_errors = Off
    error_log = /home/yourusername/logs/php_errors.log
  4. Save the file. Make sure the logs/ directory exists — create it under your home directory if it doesn’t.

⚠ Warning: The php.ini method only works when PHP is running as CGI or FastCGI (which is the default on most cPanel hosts, including ours). If PHP is running as an Apache module (mod_php), this file will be silently ignored. Check your PHP handler under MultiPHP Manager if you’re unsure.

Method 3: Enable Error Logging via .htaccess

This method works when PHP is running via mod_php, or as a fallback if the php.ini approach isn’t taking effect.

  1. Open or create .htaccess in your public_html directory.
  2. Add the following lines:

    php_flag log_errors on
    php_flag display_errors off
    php_value error_reporting 32767
    php_value error_log /home/yourusername/logs/php_errors.log
  3. Save the file. The change takes effect immediately — no server restart needed.

📝 Note: The value 32767 is the integer equivalent of E_ALL and works reliably across PHP 7.x and 8.x. Some older tutorials use E_ALL | E_STRICT, but E_STRICT was folded into E_ALL as of PHP 5.4 — you don’t need it.

How to View the cPanel Error Log

cPanel includes a built-in log viewer for Apache errors. It won’t show your PHP application errors (those go to the file you specified above), but it does capture 500 errors, permission issues, and rewrite rule problems.

  1. In cPanel, scroll to the Metrics section.
  2. Click Errors. This shows the last 300 lines of your domain’s Apache error log.

To tail your PHP error log file directly (useful if you have SSH access on a VPS or dedicated server), run:

tail -f /home/yourusername/logs/php_errors.log

This streams new log entries in real time as they’re written — the fastest way to debug a live issue without refreshing anything.

Verify Logging is Working

After enabling logging, confirm it’s actually writing by dropping a quick test into a PHP file:

<?php
error_log('Test error log entry - ' . date('Y-m-d H:i:s'));
?>

Visit that file in your browser, then check your log file. If the entry appears, logging is working. If the log file wasn’t created at all, the path you specified is likely wrong or the web server process doesn’t have write permission to that directory.

Common Issues & Troubleshooting

The log file isn’t being created

This is almost always a permissions problem. The directory you’re logging to needs to be writable by the web server user (typically the cPanel account user on suEXEC setups). Check the permissions on your logs/ directory:

ls -la /home/yourusername/logs/

The directory should be owned by your cPanel username and have at least 755 permissions. If the directory is owned by root, PHP can’t write to it.

Errors are showing on-screen instead of in the log

You have display_errors = On set somewhere — possibly in a php.ini file in a parent directory, or via an old .htaccess rule you forgot about. Run a search for any conflicting settings:

grep -r "display_errors" /home/yourusername/public_html/

The last directive PHP reads wins. A php.ini in a subdirectory overrides one in the parent directory, and .htaccess can override both depending on your PHP handler.

The Errors tool in cPanel shows nothing

The built-in cPanel Errors viewer only shows the Apache error log, not PHP application logs. If your PHP errors are going to a custom file (which they should be), you won’t see them there. You need to check the file path you set in error_log directly. Also worth noting: cPanel only shows the last 300 entries, so if your site is actively erroring, earlier entries may already be gone.

Changes to php.ini aren’t taking effect

This usually means your PHP handler is set to something that doesn’t read per-directory php.ini files. In WHM/cPanel environments running PHP-FPM (common on newer setups), per-directory php.ini files in public_html are not processed. You’ll need to use the MultiPHP INI Editor in cPanel instead, which edits the correct system-level INI for your PHP version.

Log file is growing too large

On a site with active errors, a PHP error log can balloon to hundreds of megabytes fast — especially if you have a loop generating thousands of notices per second. I’d recommend setting up basic log rotation or adding a cron job to truncate it periodically. At minimum, check the file size regularly:

du -sh /home/yourusername/logs/php_errors.log

Once you’ve fixed the underlying errors, consider setting error_reporting to exclude notices and warnings in production: E_ALL & ~E_NOTICE & ~E_WARNING — though I’d still log E_ALL in staging.

FAQ

Frequently Asked Questions

Where is the PHP error log located in cPanel?

There’s no single fixed location — it depends on what you’ve configured in your php.ini or .htaccess file via the error_log directive. A common path is /home/yourusername/logs/php_errors.log. If you haven’t set a custom path, PHP may write to the server’s default error log, which you can view under Metrics > Errors in cPanel (though that only shows Apache-level errors, not application PHP errors).

How do I turn on PHP error logging without showing errors to visitors?

Set log_errors = On and display_errors = Off in your PHP configuration. This writes errors to your log file silently, without exposing anything on screen. You can do this through cPanel’s MultiPHP INI Editor or by adding the equivalent directives to a .htaccess file. Never turn display_errors on for a live site.

Why is my error log empty even though my site has errors?

A few likely causes: the log file path you specified doesn’t exist or isn’t writable, the PHP handler in use (like PHP-FPM) isn’t reading your php.ini file, or log_errors is still set to Off somewhere. Drop a manual error_log() call into a PHP file to test whether logging is functional at all. If that entry doesn’t appear, the issue is with the path or permissions.

Does enabling error logging slow down my website?

Negligibly. Writing to a log file adds microseconds of I/O per error — nothing that will affect site performance under normal conditions. What will slow your site down is having thousands of PHP notices or warnings firing on every page load. Fix the underlying errors and the log overhead becomes irrelevant.

Can I enable error logging on managed WordPress hosting?

Yes, though the method depends on the environment. WordPress has its own debug logging built in — add define(‘WP_DEBUG’, true) and define(‘WP_DEBUG_LOG’, true) to your wp-config.php file, and errors will write to wp-content/debug.log. This works independently of the PHP-level logging covered in this article, and both can run at the same time.

SHARE THIS ARTICLE

Need help with your hosting?

Host & Tech provides 24/7 support for all VPS, dedicated, and shared hosting customers.

Scroll to Top