Updated: 10 November 2026 · Applies to: PHP 8.4 with Apache 2.4 (mod_php and PHP-FPM) on Debian 13, cPanel and WHM (MultiPHP INI Editor)
To show PHP errors in the browser, set display_errors = On and error_reporting = E_ALL for the site. The quickest test is three lines at the top of the PHP file you are debugging:
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
That works for most warnings, but not for every error. The methods below, from a single file up to the whole server, each fit a different case. Use them only while you debug: the PHP manual says display_errors "should never be used on production systems", because error messages reveal file paths and details of your code.
Why you see a blank page or "HTTP 500"
Distribution and control panel builds of PHP ship a production php.ini with errors hidden. On Debian 13 (PHP 8.4) all three php.ini files (apache2, fpm and cli) contain:
error_reporting = E_ALL & ~E_DEPRECATED display_errors = Off display_startup_errors = Off log_errors = On
With these values a fatal error gives the visitor an empty page with HTTP status 500, while the real message goes to the error log. In our test Apache logged it like this:
PHP Fatal error: Uncaught Error: Call to undefined function undefined_function() in /var/www/html/t/err.php:4
Checking the log is often enough, and it does not expose anything to visitors. On cPanel accounts look for the error_log file in the folder of the script; see WordPress Error 500 Debugging Using the error_log File.
Method 1: ini_set() in the script
Add the three lines above at the very top of the file. With them our test page printed:
<br /> <b>Warning</b>: Undefined variable $undefined_variable in <b>/var/www/html/t/ini.php</b> on line <b>5</b><br />
The limit: according to the PHP manual, ini_set() "won't have any effect if the script has fatal errors", because the line never runs. A syntax error in the same file is the typical case. For those, use one of the methods below, which apply before the script starts.
Method 2: cPanel MultiPHP INI Editor
- Log in to cPanel and open Software › MultiPHP INI Editor.
- On the Basic Mode tab, choose the domain (or the home directory for all your sites).
- Set display_errors to Enabled and click Apply.
According to cPanel's documentation, the editor writes the setting to the php.ini and .user.ini files for that directory, and to .htaccess where that file supports the directive, so it works for both PHP handlers. Set it back to Disabled when you finish.
Method 3: .htaccess with php_flag (Apache mod_php only)
If PHP runs as an Apache module (mod_php, also called the Apache handler or DSO), add this to the .htaccess file in the site folder:
php_flag display_errors on php_value error_reporting -1
-1 switches on every error level. Our test page then showed the warning and the full fatal error with its stack trace. According to the PHP manual, this needs AllowOverride Options or AllowOverride All for the folder in the Apache configuration.
Do not use these lines with PHP-FPM, FastCGI or suPHP. Apache does not know php_flag there and the whole site returns 500 Internal Server Error. Our test logged:
/var/www/html/t/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
If you see this after editing .htaccess, remove the two lines and use Method 4 instead. More on the file itself: What Is .htaccess and How to Edit It in cPanel.
Method 4: .user.ini (PHP-FPM and FastCGI)
With PHP-FPM (common on current servers, and what Nginx always uses), create a file named .user.ini in the site folder:
display_errors = On error_reporting = E_ALL
Our FPM test page then showed the errors with HTTP status 200 instead of a blank 500 page. PHP caches .user.ini files: the user_ini.cache_ttl default is 300 seconds, so a change can take up to five minutes to apply. Restarting PHP-FPM applies it at once.
Method 5: the server php.ini (root access)
On a VPS or dedicated server you can change it for every site that uses a PHP version. Find the right file first (the web server uses a different one from the command line):
php --ini
On Debian and Ubuntu the files are /etc/php/8.4/fpm/php.ini (PHP-FPM) and /etc/php/8.4/apache2/php.ini (mod_php). Set:
display_errors = On display_startup_errors = On error_reporting = E_ALL
Then reload PHP-FPM (systemctl reload php8.4-fpm) or Apache (systemctl reload apache2). To switch it on for one FPM pool only, add this line to the pool file, for example /etc/php/8.4/fpm/pool.d/www.conf, and reload:
php_admin_flag[display_errors] = on
On WHM servers use Software › MultiPHP INI Editor in WHM instead. According to cPanel, its Basic Mode lists display_errors (default Disabled) and saves it to /opt/cpanel/<PHP package>/root/etc/php.ini for the PHP version you choose.
Check that it worked
Put a small test file in the site folder and open it in the browser:
<?php
echo "display_errors=" . ini_get('display_errors') . " error_reporting=" . error_reporting() . "\n";
echo $undefined_variable;
Before the change our page showed display_errors= error_reporting=22527 (22527 is E_ALL & ~E_DEPRECATED) and no warning. After it showed display_errors=1 error_reporting=30719 (30719 is E_ALL in PHP 8.4) followed by the warning. Delete the test file afterwards.
For command-line scripts and cron jobs you do not need any of this: run php -d display_errors=1 script.php.
Turn it off again
- Remove the
ini_set()lines, thephp_flaglines or the.user.inisettings, or set display_errors back to Disabled in cPanel. - Keep
log_errors = Onso errors are still written to the log.
Official documentation: PHP runtime configuration for errors, cPanel MultiPHP INI Editor.