Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache 500 server error- logs showing nothing

Tags:

php

apache

Just after some help with a new installation of PHP.

I've setup a new Centos 6.2 server with apache PHP and am having trouble getting errors to show. I've copied all the website application files from a different as well as the folder structure and everything in /etc/httpd/.

When I access my site, I get a 500 error, or a blank page. The logs are showing nothing at all, apart form logging the 500 error:

[24/Feb/2012:17:33:25 +1100] "GET / HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1" 405 229 7176

My htaccess looks like this: ErrorDocument 404 /error.php

php_flag  display_errors                  on
php_flag  display_startup_errors          on
php_flag  file_uploads                    on
php_value error_reporting                 6143
php_value max_input_time                  60
php_value post_max_size                   8M
php_value upload_max_filesize             2M
~

So errors are turned on...

Start of PHP file has:
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

and php.ini has error_reporting set to E_ALL.

... yet I am getting errors on the screen for some things (such as not closing a string), but my issues are a bit bigger than i think and i have no idea where to start debugging!

So i guess my question is- how do I start debugging a 500 server error?

like image 786
Lock Avatar asked Feb 24 '12 11:02

Lock


2 Answers

When error messages are maddeningly missing from the screen and from the Apache error_log files and anywhere else, I've had good luck getting them to appear by adding a different PHP file, using it only for development:

<?php
 error_reporting(E_ALL);
 ini_set("display_errors", 1);
 include("productioncode.php");
?>

This way, even if productioncode.php has compile-time errors the above code runs, and the messages get displayed, unlike merely putting the first two lines at the top of productioncode.php.

@Jaspreet Chahal and @Saiyam Patel - I just recovered from a lovely evening of error 500's in the access_log, e.g.

77.22.98.222 - - [26/Feb/2012:22:38:41 -0500] "GET /buggycode.php HTTP/1.1" 500 - west-real-estate.com "-" "Mozilla/5.0 (Windows NT 5.0; rv:11.0) Gecko/20100101 Firefox/11.0" "PHPSESSID=hcd04vv9e1a316cr9miauf3bl5" - 0

and no PHP error messages in any httpd log file from (foolishly) coding { 'foo' => 'bar' } instead of array( 'foo' => 'bar' ). Using the above technique revealed the detailed error message, including the all-important line number.

like image 72
5 revs Avatar answered Nov 14 '22 22:11

5 revs


Apache 500 server error This is not a PHP error this is Server error (Server Unable to handle your request) OR may be problem with .htaccess file probably redirection

cheers

like image 28
Saiyam Patel Avatar answered Nov 14 '22 22:11

Saiyam Patel