How to Enable and Manage PHP Error Logging in cPanel

Enable or disable PHP error logging in cPanel for easier debugging and control.  Our cPanel  Support team is ready to assist you. 

Enable or Disable PHP Error Logging in cPanel

PHP error logging is crucial for maintaining the stability, performance, and security of any website that runs PHP scripts. By recording warnings, notices, and critical failures, error logs help developers and administrators troubleshoot issues quickly and keep web applications running smoothly.

In this guide, you will learn why PHP error logging matters, how to enable or disable it in cPanel, how to set a custom log path, how to manage logs with the MultiPHP INI Editor, and what to do when logs fail to appear.

Why PHP Error Logging Is Important for Your Website

Enable or disable PHP error logging in cPanel

Error logging plays a central role in diagnosing and preventing problems. It provides details about the type of error, the file and line number, and sometimes a stack trace. With this information, developers can:

  • Troubleshoot and debug faster by identifying the source of issues.
  • Optimize performance by spotting inefficient code and recurring warnings.
    Strengthen security by detecting suspicious activity such as repeated login attempts or malicious script execution.
  • Stay proactive by addressing issues before they affect end users.
  • Meet compliance requirements in industries where detailed logs are mandatory.

In short, enabling PHP error logging gives website owners full visibility into how their applications behave in real time.

How to Enable PHP Error Logging in cPanel (Step-by-Step)

When setting up WHM cPanel on AlmaLinux 9, enabling PHP error logging is an important step for monitoring issues. Most cPanel environments provide a simple way to turn on PHP error logging. Here is the step-by-step process:

  1. Log in to cPanel using your credentials.
  2. Go to the Software section and select “Select PHP Version.”
    Switch to PHP Options by clicking the button in the top right corner.
  3. Locate log_errors and set it to On.
  4. Scroll down to find error_log. Enter a file path where you want logs saved, such as:
/home/username/public_html/php_errors.log
  1. Click Save to apply your changes.

After enabling logging, errors will be stored in the specified file. If you do not set a path, PHP uses the server’s default log file. For security reasons, keep display_errors set to Off in production environments to avoid exposing sensitive details.

How to Disable PHP Error Logging After Debugging

Once you finish debugging, you may want to disable logging to prevent unnecessary file growth. There are several ways to do this:

  • Using php.ini:
    Locate the php.ini file, set log_errors = Off, and restart your web server.
  • Using .htaccess:
    Add the following lines to your site’s .htaccess file:
php_flag log_errors Off
php_flag display_errors Off
  • Using ini_set() in a PHP script:
    For script-specific control, add:
<?php
ini_set('log_errors', 'Off');
ini_set('display_errors', 'Off');
?>

Always keep display_errors = Off on live websites to prevent exposing system paths and sensitive information to visitors.

Set a Custom Path for PHP Error Logs in cPanel

Organizing logs in a custom location makes tracking  cPanel errors easier. To do this:

  1. Log in and open MultiPHP INI Editor from the Software section.
  2. Choose the domain or directory where you want the setting applied.
  3. Add or update these directives:
log_errors = On
error_log = /home/your_cpanel_username/logs/php_errors.log
  1. Save the changes.

From now on, PHP will write errors to your chosen file. You can access it anytime through cPanel’s File Manager or SSH.

Manage PHP Errors with MultiPHP INI Editor

The MultiPHP INI Editor provides both a Basic and Editor mode for controlling PHP directives.

  • In Basic Mode, you can toggle options like:
    • display_errors – show errors on screen (use only for development).
    • log_errors – record errors in a file.
    • error_reporting – define which types of errors to capture.
  • In Editor Mode, you can edit php.ini directly. For example:
display_errors = Off
error_reporting = E_ALL
log_errors = On
error_log = /home/username/public_html/error_log.log

After saving, the new configuration applies immediately. This method gives you more flexibility and fine-tuned control.

Troubleshooting When PHP Error Logs Don’t Show Up

If your error logs are not appearing, check these areas:

  1. Confirm configuration: Ensure log_errors = On and that a valid path is defined in error_log.
  2. Check permissions: Make sure the web server user can write to the log file and directory.
  3. Restart services: Restart PHP or your web server after making changes in php.ini.
  4. Check .htaccess overrides: Apache users should confirm that no php_flag directives in .htaccess are interfering with logging.
  5. Disable display_errors: If enabled, errors may appear in the browser instead of being logged.

By reviewing these settings step by step, you can usually resolve missing logs quickly.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Knowing how to enable or disable PHP error logging in cPanel helps you debug issues, improve performance, and protect your site. By managing these settings properly, you can keep your website secure, stable, and optimized.

Similar Posts