Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Enable WordPress Debugging Mode to Fix Errors - DesignLinux

May 30 2020
designlinux 0 Comments

How can you enable debugging mode in WordPress or get more information about WordPress errors displayed on a web browser? If you are a WordPress user or developer and are asking these questions, you have landed on the right resource. This guide will show you how to enable WordPress’s debugging features.

WordPress provides several powerful debugging tools both for developers and non-programmer or general users, that you can enable using available configuration options. These options once enabled help you quickly find and resolve errors by showing the detailed error information.

We will demonstrate using the following error which we encountered while setting up a dummy site for testing purposes.

WordPress Database Connection Error

WordPress Database Connection Error

When you look at this error, there is no much information that accompanies it. There could be many causes to it: the database server could be down or the database connection settings (i.e database name, database user, and the user’s password) defined in the wp-config.php configuration file could be wrong.

So how can we get more information about the above error? The WP_DEBUG option is a PHP permanent global variable that activates the “debug” mode throughout WordPress thus causing all PHP errors, notices, and warnings to be displayed on the browser.

This “debug” feature was added in WordPress version 2.3.1 and is configured in wp-config.php – one of the most important files in your WordPress installation.

By default, the “debug” feature is set to false in any WordPress installation. To enable WP_DEBUG, set it to true.

First, move into your websites installation directory e.g /var/www/html/mysite.com and then open the wp-config.php file using your favorite text editor.

$ cd /var/www/html/mysite.com
$ sudo vim wp-config.php

Look for this line.

define( 'WP_DEBUG',  false );

and change it to

define( 'WP_DEBUG', true );
Enable Debug Mode in WordPress

Enable Debug Mode in WordPress

Save the file and close it.

Now debug mode has been triggered. If we reload the page that showed the error, we can see the detailed error information as shown in the following screenshot.

WordPress Error Information

WordPress Error Information

There are additional debug options that extend WP_DEBUG that are particularly useful for WordPress developers creating plugins or themes, or any other components. They are WP_DEBUG_LOG and WP_DEBUG_DISPLAY.

The WP_DEBUG_LOG option when set to true causes all errors to be saved to a debug.log log file inside the /wp-content/ directory by default. This is useful for later analysis or processing.

define( 'WP_DEBUG_LOG', true );

But you can specify a custom log file e.g /var/log/nginx/mysite.com_wp-errors.log:

define( 'WP_DEBUG_LOG', '/var/log/nginx/mysite.com_wp-errors.log' );

And WP_DEBUG_DISPLAY controls whether debug messages are shown inside the HTML of pages or not. By default, it is set to true. To disable it, set it to false.

define( 'WP_DEBUG_DISPLAY', false );

Enable Debug Mode in WordPress Using Plugin

If you are using shared hosting, you probably don’t have access to the server backend to edit your WordPress files in this case the wp-config.php file.

Or if you simply prefer to change settings from the admin dashboard, you can install and use a plugin called “Debug Bar” which allows you to easily enable/disable WP_DEBUG from admin dashboard with a single click on the Toolbar.

The killer feature of this plugin is that it is failsafe and clever, it automatically exits the WP_DEBUG mode in case of errors.

Reference: Debugging in WordPress.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit

Related

Tags: WordPress Tips

Uname Command in Linux

Prev Post

How to Install R on Ubuntu 20.04

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 585
  • 604,547

DesignLinux.com © All rights reserved

Go to mobile version