Skip to content

Instantly share code, notes, and snippets.

@csdy
Last active August 27, 2023 14:58
Show Gist options
  • Save csdy/11e1ff5e3ebf34178c43b64a473de3f7 to your computer and use it in GitHub Desktop.
Save csdy/11e1ff5e3ebf34178c43b64a473de3f7 to your computer and use it in GitHub Desktop.
PHP — Error Display

Enabling Error Display

Server-Wide Error Display (VPS Only)

Windows (VPS Only)

Enable Error Display

  • Establish a remote desktop connection to the server
  • Open Explorer
  • Navigate to C:\PHP\X.X (where "X.X" is the PHP version you wish to modify) Note The PHP directory is located on the D: drive on shared servers
  • Open the php.ini file for editing
  • Locate the following line of code:
    display_errors = Off
  • Update the value to the following:
    display_errors = On
  • Save and close the file
  • Launch the IIS Manager application
  • Under the Connections pane in the left sidebar, click the server node
  • Under the Actions pane in the right sidebar, click the "Restart" link

Disable Error Display

  • Establish a remote desktop connection to the server
  • Open Explorer
  • Navigate to C:\PHP\X.X (where "X.X" is the PHP version you wish to modify) Note The PHP directory is located on the D: drive on shared servers
  • Open the php.ini file for editing
  • Locate the following line of code:
    display_errors = On
  • Update the value to the following:
    display_errors = Off
  • Save and close the file
  • Launch the IIS Manager application
  • Under the Connections pane in the left sidebar, click the server node
  • Under the Actions pane in the right sidebar, click the "Restart" link

cPanel EasyApache (VPS Only)

Enable Error Display

  • Login to the WHM server control panel
  • Navigate to Software > MultiPHP INI Editor
  • Select the PHP version you wish to modify
  • Set the toggle next to the display_errors directive to "Enabled"
  • Scroll to the bottom of the page and click the Apply button

Disable Error Display

  • Login to the WHM server control panel
  • Navigate to Software > MultiPHP INI Editor
  • Select the PHP version you wish to modify
  • Set the toggle next to the display_errors directive to "Disabled"
  • Scroll to the bottom of the page and click the Apply button

cPanel CloudLinux (VPS Only)

PHP errors cannot be enabled at the server-level for CloudLinux. Errors may only be enabled at the domain level. (See below for instructions.)

Per-Application Error Display (VPS, Shared)

Windows Control Panel

Enable Error Display

  • Login to the Windows Control Panel
  • Navigate to Website Settings > IIS Settings > Advanced
  • Set "Custom Error Mode" to "Detailed"
  • Click the Save button
  • Navigate to Website Settings > PHP Settings
  • Ensure that "Custom php.ini" checkbox is enabled
  • Click the Save button
  • Navigate to Files > File Manager
  • Click the Login button
  • Navigate to the wwwroot folder
  • Right-click the php.ini file and select Edit to open the file
  • Locate the following line of code:
    display_errors = Off
  • Update the value to the following:
    display_errors = On
  • Click the "Save File" button
  • Close the FileManager window and return the the Windows Control Panel dashboard
  • Navigate to Website Settings > IIS Settings > Advanced
  • Click the "Recycle" button to recycle the application pool

Disable Error Display

  • Login to the Windows Control Panel
  • Navigate to Website Settings > IIS Settings > Advanced
  • Set "Custom Error Mode" to "Detailed"
  • Click the Save button
  • Navigate to Files > File Manager
  • Click the Login button
  • Navigate to the wwwroot folder
  • Right-click the php.ini file and select Edit to open the file
  • Locate the following line of code:
    display_errors = On
  • Update the value to the following:
    display_errors = Off
  • Click the "Save File" button
  • Close the FileManager window and return the the Windows Control Panel dashboard
  • Navigate to Website Settings > IIS Settings > Advanced
  • Click the "Recycle" button to recycle the application pool

Windows Manual

Enable Error Display

  • Establish a remote desktop connection to the server
  • Open Explorer
  • Navigate to D:\home\domain.com\wwwroot (where domain.com is the customer domain)
  • Open the php.ini file for editing
  • Locate the following line of code:
    display_errors = Off
  • Update the value to the following:
    display_errors = On
  • Save and close the file
  • Launch the IIS Manager application
  • Under the Connections panel in the left sidebar, expand the server node
  • Expand the Sites node
  • Click the website for which you want to enable error display
  • Under the IIS section, double-click the Error Pages icon
  • Under the Actions pane of the right sidebar, click the "Edit Feature Settings..." link
  • Change the Error Responses mode to "Detailed errors"
  • Click the OK button
  • Under the Connections panel in the left sidebar, expand the server node
  • Click the Application Pools node
  • Click the corresponding application pool to select it
  • Under the Actions pane in the right sidebar, click the "Recycle" link

Disable Error Display

  • Establish a remote desktop connection to the server
  • Open Explorer
  • Navigate to D:\home\domain.com\wwwroot (where domain.com is the customer domain)
  • Open the php.ini file for editing
  • Locate the following line of code:
    display_errors = On
  • Update the value to the following:
    display_errors = Off
  • Save and close the file
  • Launch the IIS Manager application
  • Under the Connections panel in the left sidebar, expand the server node
  • Expand the Sites node
  • Click the website for which you want to enable error display
  • Under the IIS section, double-click the Error Pages icon
  • Under the Actions pane of the right sidebar, click the "Edit Feature Settings..." link
  • Change the Error Responses mode to "Detailed errors for local requests and custom error pages for remote requests"
  • Click the OK button
  • Under the Connections panel in the left sidebar, expand the server node
  • Click the Application Pools node
  • Click the corresponding application pool to select it
  • Under the Actions pane in the right sidebar, click the "Recycle" link

cPanel EasyApache

Enable Error Display

  • Login to the cPanel domain control panel
  • Navigate to Software > MultiPHP INI Editor
  • Select the location of the PHP configuration file you wish to modify (normally "Home Directory")
  • Set the toggle next to the display_errors directive to "Enabled"
  • Scroll to the bottom of the page and click the Apply button

Disable Error Display

  • Login to the cPanel domain control panel
  • Navigate to Software > MultiPHP INI Editor
  • Select the location of the PHP configuration file you wish to modify (normally "Home Directory")
  • Set the toggle next to the display_errors directive to "Disabled"
  • Scroll to the bottom of the page and click the Apply button

cPanel CloudLinux

Enable Error Display

  • Login to the cPanel domain control panel
  • Navigate to Software > Select PHP Version
  • Click the Options tab
  • Enable the checkbox next to the display_errors directive
  • Changes are saved automatically

Disable Error Display

  • Login to the cPanel domain control panel
  • Navigate to Software > Select PHP Version
  • Click the Options tab
  • Disable the checkbox next to the display_errors directive
  • Changes are saved automatically

Additional Considerations

Many PHP applications (such as WordPress, Joomla, Drupal, et al.) and development frameworks (such as Laravel, CakePHP, CodeIgniter, et al.) use configuration files to dynamically enable/disable debugging and error display.

WordPress

  • Open the wp-config.php file in the application root
  • Locate the following line of code:
    define( 'WP_DEBUG', false );
  • Update the value as follows:
    define( 'WP_DEBUG', true );
  • Save and close the file
  • When debugging is complete, reverse your changes

Joomla

  • Open the configuration.php file in the application root
  • Locate the following line of code:
    public $debug = false;
  • Update the value as follows:
    public $debug = true;
  • Save and close the file
  • When debugging is complete, reverse your changes

Laravel

  • Open the .env file in the application root
  • Locate the following line of code:
    APP_DEBUG=false
  • Update the value to the following:
    APP_DEBUG=true
  • Save and close the file
  • When debugging is complete, reverse your changes

CakePHP

  • Open the config/app_local.php file
  • Locate the following line of code:
    'debug' => filter_var(env('DEBUG', false), FILTER_VALIDATE_BOOLEAN),
  • Update the value to the following:
    'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
  • Save and close the file
  • When debugging is complete, reverse your changes

CodeIgniter

  • Open the .env file in the application root

  • Locate the following line of code:

    CI_ENVIRONMENT = production
  • Update the value to the following:

    CI_ENVIRONMENT = development
  • Save and close the file

  • When debugging is complete, reverse your changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment