Here is a quick reminder on how to enable the php error log using htaccess files.
If you suspect that your php applications are dying or creating errors and you want to collect that data for debugging do the following.
inside the directory where you have your php scripts create an htaccess files
pico -w .htaccess
enter the following.
php_flag log_errors on
php_value error_log errorlog.txt
save the file . then create the file that will store the error.
touch errorlog.txt
then you might have depending on your setup make it writeable by the apache user or whatever user is running
apache on my server the user is nobody
chown nobody:nobody errorlog.txt
you might not have to do that on your server so it is trial an error.
Then so make sure your error is turned on you need a way to verify that it is working .
Create the following file.
print("The next line generates an error.
“);
printaline(”PLEASE?”);
print(”This will not be displayed due to the above error.”);
?>
save the file.
if everything is working access that file using your browser
http://www.yoursite.com/generate.php
hit refresh a few times so the page generates more errors to the log file.
in the mean time, you will see the following being displayed on the browser.
The next line generates an error.
now let’s check to see if your errorlog.txt file has any juicy info :) ( if you don’t see anything chown apache:apache the errorlog.txt file .
if you look at that file you will see the following.
[01-Mar-2007 17:34:17] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:25] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:26] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:27] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:27] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:27] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:27] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:27] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:27] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:28] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:28] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
[01-Mar-2007 17:34:28] PHP Fatal error: Call to undefined function printaline() in /www/htdocs/your-directory/mytestphp/generate.php on line 3
ok, that is all for today fellow penguin readers.
We will come back again with more useless tips for you :)