if the user has only (S)FTP access to the webserver:
- download the file.php that throws errors
- open it up in an text-editor
- place this right after <?php
<?php
# place this right at the start of the file.php that needs debugging
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
creditz: https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display
if the admin-user has ssh access to the webserver:
global and permanent: activate logging to file and html output:
-
vim /etc/php5/cgi/php.ini # open up your default configuration file, how to find the default config check here ; check that these options are On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = On
log_errors = On
html_errors = On
; this is the file the errors will be written to error_log = /var/www/php_errors.log ; if you can not find php_errors.log another default filename for logs is script_errors.log
after changes @ php.ini – don’t forget to restart your webserver!
/etc/init.d/lighttpd restart
per-file and temporary error logging:
Set error logging with ini_set()
Although this is not ideal you can use the ini_set() function to set the above configuration options to log errors. It is not an ideal solution because it will not log any errors if the script has parse errors and cannot be run at all. For example:
<?php
# enable output of errors directly in the file.php
ini_set("log_errors", 1);
ini_set("error_log", "/path/to/php-error.log");
Set error logging in .htaccess and virtualhost directives
This is a better option because it will log the errors even if there’s a parsing error in your script.
php_value log_errors 1 php_value error_log /path/to/php-error.log
Example error log data
A couple of example lines from an error log are as follows:
[13-May-2009 21:54:04] PHP Notice: Undefined variable: x in /common/websites/test/error-log.php on line 6 [13-May-2009 21:54:09] PHP Parse error: syntax error, unexpected '}' in /common/websites/test/error-log.php on line 5
http://www.electrictoolbox.com/log-php-errors-log-errors-error-log/
if you want see errors as they happen in “real-time” you can use
less /var/www/php_errors.log
and thenn hit: Shift+F -> Follow file changes
there is also a: Webserver Error log
lighttpd error log:
less /var/log/lighttpd/error.log
liked this article?
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!
