PHP doesn't show any kind of errors

PHP doesn't show any kind of errors

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Why display_errors Appears Off Despite Being Enabled in Configuration

You've configured your PHP environment to report every error, restarted Apache multiple times, and even checked phpinfo(). Yet, when you trigger a fatal exception, the page remains blank or shows the default "Internal Server Error" from Apache instead of the expected stack trace. The moment you switch to an application-level call like ini_set('display_errors', 'on'), the errors start appearing. This discrepancy between your php.ini settings and the actual runtime behavior points to a specific architectural reality: configuration files do not always apply globally or uniformly across all contexts in a web server environment.

The root cause here is almost certainly how Apache loads PHP modules. In setups using the legacy PHP 5.3 stack on older Ubuntu distributions, Apache often loads PHP via an LoadModule directive that points to a specific module file (like libphp5.so). Crucially, this module might be initialized with its own isolated configuration context or loaded before the main php.ini is fully parsed, leading to settings being ignored if not explicitly passed. Alternatively, and more commonly in older setups, Apache might be loading PHP through a separate configuration file rather than the global php.ini. If your display_errors = on directive exists only in /etc/php5/apache2/php.ini but the module is loaded from a directory with its own defaults, or if Apache is using a different SAPI handler (such as mod_php vs. CGI/FastCGI), the effective configuration at runtime can differ significantly from what you see in the text files.

Consider this scenario: your global php.ini sets display_errors = on, but Apache's specific virtual host configuration or the module initialization script overrides it. In many shared hosting or legacy VPS environments, administrators find that directives set in the main config are ignored if they conflict with module-level defaults. The fact that ini_set('display_errors', 'on') works confirms that PHP's internal state can be changed at runtime; however, this method is generally discouraged for production because it bypasses server-level security controls and configuration management.

To resolve this without relying on application-level hacks, you need to verify exactly which configuration file Apache is using. Run the following command from your shell:

php -i | grep display_errors

This command forces PHP to read its effective configuration directly, bypassing web server caching or module isolation issues. If display_errors still shows as Off, inspect your Apache error logs (/var/log/apache2/error.log) for messages indicating a failed directive parsing or a conflict with php_flag directives in .htaccess files. Older versions of Apache and PHP (like the 5.3.x era mentioned in your source material) often required explicit use of php_flag instead of php_value for boolean settings in some configurations, though php.ini usually handles this automatically.

Another common pitfall involves error logging versus display. Even if display_errors is off, you can ensure errors are logged by setting log_errors = on and specifying a valid error_log path. This allows you to debug issues via the server logs even when the browser sees nothing, which is a best practice for any non-debugging environment.

Finally, remember that phpinfo() reflects the configuration at the time the request was processed. If your application loads early in the request lifecycle and modifies settings before phpinfo() runs, you might see different results than expected. However, since display_errors is a server-level setting, it should ideally be set in the php.ini file or via an Apache directive like:

PHPFlag display_errors On

in your virtual host configuration. If you are using FastCGI (via libfcgi or spawn-fcgi), ensure that the php-fpm.conf or the CGI wrapper is also configured to allow error display, as these processes often run with stricter defaults than Apache's mod_php. By aligning your server-level configuration with how the SAPI handler interprets directives, you eliminate the need for runtime overrides and restore consistent error visibility across your development stack.

Our network