11
votes

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?

3
You log entry shows a 200 status code. - Bart
sometimes .htaccess files might interfeer with other .htaccess files in subfolders - chepe263
I know this is old and closed, but I had a similar issue. Turns out, I had short tags in my code "<?". So I didn't have "<?php", This was causing the page to crash with no discernible error output. - Perelx
Why was this closed? Only one of the five users who closed this question, @hjpotter92, has any php experience in their tags. It's as if they read the title alone and assumed it was an Apache question. It's not. It's about finding error messages in PHP, a programming language. - Bob Stein

3 Answers

14
votes

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.

1
votes

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

1
votes

just try to check from your config file where are the logs stored. What you showed is an access log not error log I guess. so just check where is error log getting stored. Cheers! As you said its centos Check this directory /var/logs/httpd and check for error_log file. if its a custom log then search for that file.

btw 500 is a server error so for me I think it has to do something with your configuration or db connection setup.