Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu PHP5/Apache2 - Displaying 500 error instead of error message

The following script is not outputting error messages to the browser. Instead it results in an HTTP Error 500 response.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');

phpinfo();

echo "test" asdf // This should error
?>

Ideas? This is a basic php5/apache2 install on ubuntu. httpd.conf is blank, no .htaccess file.

The error.log file displays the error message:

syntax error, unexpected T_STRING, expecting ',' or ';'

which is correct.

like image 258
EmpireJones Avatar asked Mar 10 '11 05:03

EmpireJones


1 Answers

<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

phpinfo();

echo "test" asdf // This should error
?>

In error_reporting -1 shows even more than E_ALL and for display_errors I used the value 1 instead of On.

http://php.net/manual/en/function.error-reporting.php http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors

Edit: I got the answer!

If the script has a parse error that prevents it from running, this also prevents it from > changing a PHP setting.

https://serverfault.com/questions/242662/ubuntu-php5-apache2-displaying-500-error-instead-of-error-message

like image 114
Daniel Kutik Avatar answered Nov 04 '22 01:11

Daniel Kutik