How do I log PHP errors in Lightsail?

1 minute read
0

I want to configure PHP error reports in Amazon Lightsail.

Resolution

To log PHP errors in Lightsail, complete the following steps:

Locate the PHP configuration file

  1. Use SSH to connect to Lightsail.

  2. Locate the php.ini file:

    $ php -i | grep php.ini
    Configuration File (php.ini) Path => /opt/bitnami/php/lib
    Loaded Configuration File => /opt/bitnami/php/lib/php.ini
  3. Open the file:

    vi /opt/bitnami/php/lib/php.ini
  4. Edit the php.ini file to configure error directives based on your use case. Below are four common error directives:
    log_errors: activate this directive to turn on error logs.
    error_reporting: set to E_ALL to report all PHP errors.
    display_errors: activate to display errors in the browser during tests. It's a best practice to deactivate display_errors when your WordPress application is in production.
    error_log string: enter the location where you want to save the error logs. If log_errors is activated and error_log isn't defined, then errors are reported in the /opt/bitnami/apache2/logs/error_log file by default.
    Note: For more information as well as a full list of error directives, see Runtime configuration in PHP's official documentation.

  5. To apply your changes, restart Bitnami:

    sudo /opt/bitnami/ctlscript.sh restart
AWS OFFICIAL
AWS OFFICIALUpdated 3 months ago