Managing PHP errors: Difference between revisions

From ULYSSIS documentation
No edit summary
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
PHP errors are not displayed by default. If an error occurs, you will simply get a blank page. This is for security reasons: this way, an attacker doesn't know about possible vulnerabilities of your website. If you want to see PHP errors, you can log them to a file, or enable the display of errors.
PHP errors are not displayed by default. If an error occurs, you will simply get a blank page. This is for security reasons: this way, an attacker doesn't know about possible vulnerabilities of your website. If you want to see PHP errors, you can log them to a file, or enable the display of errors. Note that it can take up to 5 minutes for any of the options mentioned below to be detected.


= Logging errors to a file =
== Logging errors to a file ==


If your username is ''foobar'', create a <code>.htaccess</code> file (for example: <code>~/www/.htaccess</code>) with this content, if you are a regular user:
If your username is ''foobar'', create a <code>.user.ini</code> file (for example: <code>~/www/.user.ini</code>) with this content, if you are a regular user:
  php_flag log_errors on
  log_errors = on
  php_value error_log /home/user/foobar/php_error.log
  error_log = "/home/user/foobar/php_error.log"


Or if you are an organization:
Or if you are an organization:
  php_flag log_errors on
  log_errors = on
  php_value error_log /home/org/foobar/php_error.log
  error_log = "/home/org/foobar/php_error.log"


= Displaying errors =
== Displaying errors ==


Create a <code>.htaccess</code> file (for example: <code>~/www/.htaccess</code>) with this content:
Create a <code>.user.ini</code> file (for example: <code>~/www/.user.ini</code>) with this content:
  php_flag display_errors on
  display_errors = on
 
Note that PHP errors may include sensitive information, and enabling <code>display_errors</code> will cause that to be visible to the entire internet. It is therefore advised to only enable <code>display_errors</code> when actively troubleshooting a problem. Instead use an error log as specified above.
 
[[Category:Webserver]]

Latest revision as of 00:05, 9 July 2020

PHP errors are not displayed by default. If an error occurs, you will simply get a blank page. This is for security reasons: this way, an attacker doesn't know about possible vulnerabilities of your website. If you want to see PHP errors, you can log them to a file, or enable the display of errors. Note that it can take up to 5 minutes for any of the options mentioned below to be detected.

Logging errors to a file

If your username is foobar, create a .user.ini file (for example: ~/www/.user.ini) with this content, if you are a regular user:

log_errors = on
error_log = "/home/user/foobar/php_error.log"

Or if you are an organization:

log_errors = on
error_log = "/home/org/foobar/php_error.log"

Displaying errors

Create a .user.ini file (for example: ~/www/.user.ini) with this content:

display_errors = on

Note that PHP errors may include sensitive information, and enabling display_errors will cause that to be visible to the entire internet. It is therefore advised to only enable display_errors when actively troubleshooting a problem. Instead use an error log as specified above.