StefanRSA Posted May 12, 2011 Share Posted May 12, 2011 Hi, I receive 500 server errors on my system for a certain page. When I go into the error_log nothing is in the log about the error. On top of the page I have: set_time_limit (0); error_reporting(E_ALL ^ E_NOTICE); My php.ini display_errors is off display_startup_errors is on error_reporting is E_ALL & ~E_NOTICE & ~E_DEPRECATED How can I get the system to show me where the errors are? Am I missing anything? Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/ Share on other sites More sharing options...
requinix Posted May 12, 2011 Share Posted May 12, 2011 Turn display_errors=on, for starters. Are you sure you have the right error log file? WAMP, for one, can mess around with file paths... Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214316 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 Thanks for replying Requinix. The system I am working on is live... Cannot display errors onscreen... I am looking at both error_log in cPanel and log_error.doc in folder. Where else should I look? Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214325 Share on other sites More sharing options...
jonsjava Posted May 12, 2011 Share Posted May 12, 2011 try this: <?php ini_set("display_errors","1"); //code here A warning: if the script is having a fatal error, this won't work. Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214331 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 Negative... <php ini_set("display_errors","1"); /// Code Here is not working either. Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214348 Share on other sites More sharing options...
jonsjava Posted May 12, 2011 Share Posted May 12, 2011 Fatal error. Means that either the parsing engine is acting up (PHP is crapping itself), or Apache doesn't like something you are trying to do. Do you have a .htaccess file associated with this? Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214350 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 The site uses sphider as search. In the root folder of sphider system the .htaccess reads # 1. prevent listing of folders Options -Indexes # # 2. Redirect client enquiries to search.php RewriteEngine on RewriteRule ^search\.html$ ./search.php # # 3. Always start with this file DirectoryIndex search.php # # 4. Prevent delivery of .htacess file <FilesMatch "^.htaccess" > deny from all </FilesMatch> # # 5. Enable Apache to use php includes AddType application/x-httpd-php .htm .html # # 6. Unset Magic quotes php_flag magic_quotes_gpc off # End of file It also has a php.ini file that reads: allow_url_fopen = on; Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214353 Share on other sites More sharing options...
Adam Posted May 12, 2011 Share Posted May 12, 2011 "display_errors" and "error_reporting" are for PHP-level errors, not Apache server errors. Generally the two aren't related, but there's certain situations where PHP code could cause a server error. Infinite redirect loops are a common cause for getting an odd 500 error, and bad rewrite rules / server configuration as I think jonsjava is getting at. Also remember that Apache's error log is not the same as the PHP error log. What do you actually do in the code behind this page that doesn't work? Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214356 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 It is the sites search page. The strange thing is that the error happens only with certain words or search phrases searched for. If you search for "Car for Sale" all is fine.... If you search for a word not in the index all is fine.... If you search for "spa bath" the error kicks in. I was thinking the error_log could help me... But no entry is written into the error_log and the page load halfway and exits.... 500 Error Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214361 Share on other sites More sharing options...
jonsjava Posted May 12, 2011 Share Posted May 12, 2011 Ok, we have guessed about as far as we can without actually seeing code. If you are willing, could you post what you are able to of the code in question? Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214363 Share on other sites More sharing options...
Adam Posted May 12, 2011 Share Posted May 12, 2011 Does it show the server error every time you search for "spa bath", or sporadically? Also are you sure you're checking the Apache error log, and not PHP's error log? Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214364 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 Mmmm... Not sure where to look and if I would look at the right log? Was thinking the cPanel log or error_log file in the search system folder will help... Where do I look for the Apache error log? I had the system once earlier today displaying results... Strangely... After the search is done the cache for the search actually shows results that should have displayed.... $wr_handle = fopen ("".$textcache_dir."/".$cache_query."_".$type."_".$category.".txt", "r"); Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214374 Share on other sites More sharing options...
Adam Posted May 12, 2011 Share Posted May 12, 2011 I couldn't say to be honest, I don't use cPanel. Do you have SSH access to the server? I'd guess that if the search is working on and off, the server doesn't like what it's doing (albeit performance issues, high memory usage, etc.) and is failing occasionally. What kind of hosting do you have? Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214402 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 Yes, have SSH. Working on a dedicated server with WHM and cPanel Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214419 Share on other sites More sharing options...
jonsjava Posted May 12, 2011 Share Posted May 12, 2011 you should have a ~/logs or ~/var/log directory. find that, and in there, you should have httpd or apache folder in that folder, you should have error.log also, you should have a ~/php or ~/var/log/php directory Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214423 Share on other sites More sharing options...
Adam Posted May 12, 2011 Share Posted May 12, 2011 you should have a ~/logs or ~/var/log directory. find that, and in there, you should have httpd or apache folder in that folder, you should have error.log also, you should have a ~/php or ~/var/log/php directory Those are specific to your hosting provider, likely a shared hosting, which is why they've been set-up within your home directory ("~/") as you won't have access to the root directories. On a dedicated server StefanRSA, you'll probably have the normal paths to the log files. Unfortunately that can vary between Unix distributions, so you may need to look around a bit. You should be able to find the Apache files within /etc/httpd/ or /etc/apache2, which should have an alias to the logs directory. In there you should be able to find the Apache error log. Edit If not you can use the grep or find commands to find the file. Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214437 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 Thanks Mr Adam. I am searching around. I found an error_log in the public_html folder. Its 45Mb so am downloading it to see if that is the one I am looking for. Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214440 Share on other sites More sharing options...
Adam Posted May 12, 2011 Share Posted May 12, 2011 If you have SSH access, to prevent you having to download a 45mb log file, just use: cat error_log | less That will show you the first x lines of the log (x depending on the size of your screen) so you'll be able to tell first if it's the right one. Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214442 Share on other sites More sharing options...
StefanRSA Posted May 12, 2011 Author Share Posted May 12, 2011 Damn.... Got the error_log in /usr/local/apache/logs Not sure but think its the same log file as in cPanel Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214546 Share on other sites More sharing options...
Adam Posted May 12, 2011 Share Posted May 12, 2011 Okay, right.. cd to the Apache directory within /etc/ and run the following grep search: grep -r ErrorLog * That should find the ErrorLog directive which contains the path to the server's error log. Quote Link to comment https://forums.phpfreaks.com/topic/236180-500-error-but-nothing-in-error_log/#findComment-1214555 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.