Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I keep getting

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.

Whenever there is something wrong with my php code. I am using ubuntu 11.04 with apache2 and php installed.

share|improve this question
And your question is how to code better in php? ;-) – Rinzwind Sep 11 '11 at 18:52
I guess you want to have the PHP error visible instead of Apache's response? – Lekensteyn Sep 11 '11 at 18:58

If you're looking to debug your php code you'll want to run tail -f /var/log/apache2/error.log this will have detailed information about why the 500 error was triggered.

Here is an example from my error log that recently threw a 500 error

[Sun Sep 11 22:54:16 2011] [error] [client] PHP Fatal error: Call to a member function sql_query() on a non-object in /home/marco/Projects/Ondina/cp/apps/domains/databases.d.php on line 170

This shows the file source that threw the error, the line, and the exact error message. From those three variables you should be able to locate and fix any issues with your code.

share|improve this answer

You can enable display_errors and disable log_errors in the php.ini file ( /etc/php5/apache2/php.ini ). But note that for a live site it is much better to log errors than to show an error on the web page, because such an error may contain information which you don't want to leak.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.