CodeIgniter parse errors display but not written to log - apache

I'm attempting to build an error handling service for my CodeIgniter apps, and everything is logged as expected except parse errors. For example,
Parse error: syntax error, unexpected T_VARIABLE in /var/www/foo/web/app/controllers/foo.php
... will output and get logged by Apache under E_ALL. All other (non-parse) errors get passed to the log_exception extension I've written in /core/MY_Exceptions.php, and show up in CI's logs with PHP 5.2.17 and 5.3.6 (MAMP). Parse errors will display in Apache's native error log, but NOT in CodeIgniter's logs – they seem to miss CodeIgniter altogether.
How can I ensure that parse errors get picked up by CI? Am I missing something obvious?

This may help you: Why is codeigniter not logging error!
If the page is failing to load because of a parse error, then it'll
never execute
error_reporting(E_ALL);
so you script will never know to output the error. Edit your php.ini
file to make sure you have:
error_reporting = E_ALL
error_log = "/path/to/some/apache/writable/file"
Hope this helps.

Related

How can I intentionally create a server error on apache to test error log

I'm on network solutions apache server. On their setup page I chose to enable error logging. Nothing ever seems to appear in the log folder though. I suppose that could be good if I really have no errors. How could I create an error that should show up in the log folder so I can test it.
If you have enabled dynamic scripts, how about a script that dies or won't compile?
#!/usr/bin/env perl
die "This script intentionally produces HTTP 500";

How to simulate a 500 http error on apache

I read about a lot of ideas about how to test the ErrorDocument 500 directive, but they don't work. If I put bad php code, I still get a page with my php error in it. If I create a bad htaccess file, I get the following error and not my custom error :
[an error occurred while processing this directive] The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. [an error occurred while processing this directive]
I need to raise this custom error page to ensure that it works even though most applications will manage their own 500 pages.
Thanks
PHP errors aren't 500 errors. Apache is fine. PHP has encountered the error. This can be hidden in PHP.ini, but it results in a "white screen of death" instead.
On to the .htaccess problem. The .htaccess file controls the custom error pages for your site. If Apache cannot parse the custom error pages in this file it means there are no custom error pages set to display.

apache seems to ignore "Internal Server Error" returned by CGI script

I'm writing a Python CGI script and trying to test the behaviour of the system when I need to return Status: 500 Internal Server Error.
My script is something like that:
#!/usr/bin/env python3
print("Content-type: text/html")
print("Status: 500 Internal Server Error")
print()
When I run this script there is a report in apache access log with code 500, but it's not reported in the error log. I also don't get a "500 page" in the browser.
If an internal error is caused by some other means (e.g., a script that is not executable, or contains bad HTTP header) I do get the "normal" behaviour of internal server error.
It seems like apache is ignoring, somehow, the status returned from (my) CGI scripts. I've searched for an answer but couldn't find anything.
Just for clarity, CGI is working fine on this server in any other aspect.
Any thoughts? Am I missing something?
Thansk,
Amit
Answering to myself: it seems that I was barking up the wrong tree. Based on some clues and more empirical results, It seems that when passing a request to an external script (e.g. a cgi script, php etc) the apache server expects the external script to handle any error, and it's the responsibility of the external script's to return a document that includes the error code and an error message. The external script is also responsible to log the error (it's usually enough to print it to the standard error, and it'll be picked by apache and be written to its error log).
So, for example, if my cgi script needs to report an "Internal Server Error" it is not enough to return just the header (see in my question), but it should create and return the whole error message, in HTML format. In addition, it should print an error message to the standard error.
I haven't found an official source for that, but perhaps I somehow overlooked it.

How to debug a 404 error on apache server ( lamp )?

I came across 404 error a few times and i have difficulties in debugging this kind of problem.
What is the strategy and tools available to analyse such problems (firebug, logs...).
How to differentiate and fix the cause ?
page not existing ,wrong path , redirection and rewriting ,server problem ...
404 error code means that a file is not found for whatever reason.
Just check that the file exists and that the path you use is right.
You can analyse sent requests and received responses headers and body in your browser's developper console if you want more details about why some request failed.

Weird 404 error in application.log and getting YII to ignore them?

Something is access my site using this URL:
/(Yvax:%20uggc:/jjj.tbbtyr-nanylgvpf.pbz/hepuva.wf)uggc:/jjj.tbbtyr-nanylgvpf.pbz/hepuva.wf
So I get error:
[error] [exception.CHttpException.404] exception 'CHttpException'
Is it something to worry about?
How can I stop YII from reporting on this specific error and other similar 404 errors that are unwanted?
Probably just a scanner script. We get hit by these all the time. Review security, but as long as that checks out you should be fine.