How to enable debugging in a WordPress installation through cPanel Print

  • 0

Introduction

Debugging is a crucial part of troubleshooting issues in a WordPress installation. Whether it's a theme conflict, plugin issue, or a core error, enabling debugging helps identify and log errors for resolution. In this guide, we'll walk you through enabling debugging in WordPress using cPanel File Manager.


Steps to Enable Debugging in WordPress

Step 1: Log in to Your cPanel Account

  • Open your hosting provider’s cPanel login page.
  • Enter your username and password, then click Log In.

Step 2: Open the File Manager

  • Locate and click on the File Manager icon, usually found in the Files section of cPanel.
  • This will open a file management interface where you can access your WordPress files.

Step 3: Navigate to the WordPress Root Directory

  • The root directory for your WordPress installation is often located in the public_html folder or a subdirectory within it (e.g., public_html/yourdomain.com).
  • Navigate to the directory where your WordPress files are stored.

Step 4: Locate and Edit the wp-config.php File

  1. In the root directory, find the wp-config.php file. This file contains the configuration settings for your WordPress site.
  2. Right-click on the wp-config.php file and select Edit or Code Edit from the context menu.
    • A text editor window will open, allowing you to modify the file.

Step 5: Add Debugging Code

  • In the wp-config.php file, locate the following line:

    /* That's all, stop editing! Happy publishing. */
    
  • Just before this line, add the following code to enable debugging:
    // Enable WP_DEBUG mode
    define('WP_DEBUG', true);
    
    // Enable Debug logging to the /wp-content/debug.log file
    define('WP_DEBUG_LOG', true);
    
    // Disable display of errors and warnings
    define('WP_DEBUG_DISPLAY', false);
    @ini_set('display_errors', 0);
    ​
  • Explanation of the Code:

    • WP_DEBUG: Enables debugging mode in WordPress.
    • WP_DEBUG_LOG: Logs errors and warnings to a file named debug.log in the wp-content directory.
    • WP_DEBUG_DISPLAY: Prevents errors and warnings from being displayed on the website frontend.
    • @ini_set('display_errors', 0): Ensures error messages are suppressed.

Step 6: Save Changes

  • After adding the code, click Save Changes in the editor.
  • Close the editor to finalize the update to the wp-config.php file.

How to Access Debug Logs

Once debugging is enabled, WordPress will log errors and warnings to a file named debug.log within the wp-content directory.

  • Access via File Manager:

    • Navigate to the wp-content directory using cPanel File Manager.
    • Locate the debug.log file and open it to view logged errors.
  • Access via FTP Client:

    • Use an FTP client like FileZilla to connect to your site and navigate to wp-content/debug.log.

Important: Disable Debugging After Use

Leaving debugging enabled can pose security risks and affect performance. Once you've resolved the issues, disable debugging by reverting the changes in the wp-config.php file:

  • Open the wp-config.php file in the editor.
  • Remove the lines of code you added for debugging.
  • Save the changes and close the editor.

Best Practices for Debugging in WordPress

  1. Backup Before Editing: Always create a backup of your site before modifying configuration files.
  2. Use Staging Environments: Perform debugging on a staging site to prevent disruption to your live website.
  3. Combine With Other Tools: Use debugging tools like Query Monitor or Log Viewer plugins for enhanced insights.
  4. Monitor Security: Ensure debugging is disabled when not in use to protect sensitive data.

Conclusion

Enabling debugging in WordPress is a powerful way to identify and troubleshoot issues. By following this guide, you can safely enable and use debugging through cPanel. Remember to disable debugging mode once you’ve resolved the errors to maintain your website’s security and performance.


 


Was this answer helpful?

« Back