GoAdmio

displaystartuperrors

Show or set PHP's display_startup_errors value in every php.ini on the server

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/displaystartuperrors controls PHP's display_startup_errors setting. It decides whether PHP shows errors that happen while PHP itself is starting up, before any script runs. A typical example is an extension that fails to load. The setting is separate from display_errors, which covers errors raised by scripts (see displayerrors).

The command writes the value into every php.ini it finds, for all installed PHP versions, and then schedules a PHP-FPM reload so the change takes effect.

The command sets a value. It does not flip the setting back and forth. With no value it always sets Off.

[!WARNING] Startup errors can reveal file paths and server details. Keep the setting Off on live websites. Turn it On only while you are tracking down a startup problem, then switch it Off again.

PHP 8.0 and later treat the setting as On when php.ini doesn't mention it, so writing an explicit value is worthwhile.


Quick start

# Show the current value
/go/displaystartuperrors return

# Turn it off (recommended for live sites)
/go/displaystartuperrors

# Turn it on while troubleshooting
/go/displaystartuperrors On

Syntax

# Show the current value
/go/displaystartuperrors return

# Set the value
/go/displaystartuperrors <value>

# Turn it off
/go/displaystartuperrors

Run the command as root.


Arguments

Argument Required Notes
return No Prints the current value and changes nothing. Not case-sensitive.
<value> No The value to write, usually On or Off. PHP also accepts values such as 1 and 0. The value is not checked.
(none) No Sets Off.

Pass only the value. The command writes all of its arguments into php.ini, so extra words or options, such as On --progress, end up in the file.


Output

Display Startup Errors updated successfully.

The message is printed after the files have been processed, even if no php.ini was found.

With return, the command prints the current value, for example Off, and exits with status 1, even though nothing went wrong. A blank line means no value is set.

Message Meaning
Display Startup Errors updated successfully. The run finished.
Unknown operating system. The OS is not AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, or Ubuntu. Nothing is changed.

Examples

# Turn startup errors on, reproduce the problem, then turn them off
/go/displaystartuperrors On
php -v
/go/displaystartuperrors
# Check the value that PHP on the command line is using
php -r 'echo ini_get("display_startup_errors"), PHP_EOL;'
# Compare the value in every php.ini
sudo grep -H '^display_startup_errors' /etc/php.ini /etc/opt/remi/*/php.ini 2>/dev/null

Troubleshooting

Symptom Likely cause Fix
The change isn't active on my sites The PHP-FPM reload runs about a minute later. On servers using mod_php, the web server is not reloaded by it. Wait a minute. On mod_php servers, run reload.
php.ini contains display_startup_errors = On --progress An extra argument was passed after the value. Run the command again with only the value.
display_startup_errors = --progress was written The first argument was an option, not a value. Run the command again, with no argument or with On or Off.
Display Startup Errors updated successfully. but nothing changed No php.ini file was found. Check that PHP is installed and look for the files with the grep example above.
PHP prints startup errors and I need to find the cause An extension or a php.ini line is broken. Run checkphpini, which scans every php.ini for startup errors.
atq: command not found The at package is missing. Install it with your package manager, or run fpm yourself. disablefunctions installs it automatically.
Permission denied The command was not run as root. Run it as root.
return prints an empty line The first php.ini found has no display_startup_errors line. Check every file with the grep example above.
Unknown operating system. The OS is not supported. Edit php.ini by hand.

Details

Files it changes

Operating system Files
AlmaLinux, Rocky, CentOS, Red Hat, Fedora /etc/php.ini and /etc/opt/remi/<version>/php.ini for each version found.
Debian, Ubuntu /etc/php/<version>/fpm/php.ini, cli/php.ini, and apache2/php.ini for each version found.

Files that don't exist are skipped. The Debian and Ubuntu list includes the command-line (CLI) configuration, so command-line PHP scripts and cron jobs are affected too.

What it does

flowchart TD
    A["displaystartuperrors [return or value]"] --> B{"Supported OS?"}
    B -- "No" --> X["Print Unknown operating system"]
    B -- "Yes" --> C["Build the list of php.ini files"]
    C --> D{"First argument is return?"}
    D -- "Yes" --> E["Print the first value found, exit 1"]
    D -- "No" --> F["For each php.ini: replace or add display_startup_errors"]
    F --> G["Print Display Startup Errors updated successfully."]
    G --> H{"Reload already scheduled?"}
    H -- "No" --> I["Schedule fpm reload in 1 minute"]
    H -- "Yes" --> J["Done"]
    I --> J
  1. Appends the call to /var/log/go/displaystartuperrors.log.
  2. Builds the list of php.ini files for the OS.
  3. With return, prints the value from the first file that exists, and stops.
  4. Otherwise, in each existing file, replaces the display_startup_errors = line with the new value. If the file has no such line, it adds one at the end. A commented-out line (starting with ;) is left alone, and a new line is added.
  5. Prints the confirmation.
  6. Schedules /go/fpm reload to run one minute later, unless a reload is already waiting in the at queue.

Side effects


See also

Command Description
displayerrors Show or set PHP's display_errors value (default On) in every php.ini on the server
errorreporting Read or set PHP error_reporting across all php.ini files
checkphpini Scan every php.ini for startup errors and remove the offending line
disablefunctions Show, set, or clear PHP's disable_functions setting in every php.ini on the server
fpm Restart all installed PHP-FPM versions on your server
reload Reload PHP-FPM and the active web server