1

I have an Apach Http Server that started to fail for one of its virtual hosts with a 500 error. I went straight to the logs, triggered the problem and the result was a normal entry in the access log and no mention in the error logs.

This is running PHP so I run

php index.php

on the directory of the app and it run just fine. It's not a PHP problem, or rather, it's unlikely.

I set LogLevel to debug and what I see in the error logs is just this:

[Sat Jul 04 08:41:10 2009] [error] [client 84.72.21.12] File does not exist: /var/www/example.com/public/favicon.ico, referer: http://example.com/

and in the access log:

84.72.21.12 - - [04/Jul/2009:08:40:29 -0400] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.18 (KHTML, like Gecko) Version/4.0.1 Safari/530.18"
84.72.21.12 - - [04/Jul/2009:08:40:29 -0400] "GET /favicon.ico HTTP/1.1" 404 361 "http://example.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.18 (KHTML, like Gecko) Version/4.0.1 Safari/530.18"

Any ideas what else to try?

Pablo
  • 7,249
  • 25
  • 68
  • 83
  • 3
    Is there an entry in the error log? – theotherreceive Jul 04 '09 at 04:03
  • Restart Apache (or the whole computer) maybe... if that doesn't fix it, we need more information. How did you trigger the problem? What is the line from the access log? Is the LogLevel set at debug, and once it is, what's in the error log? In a pinch, try running Apache from a terminal in debug mode (something like "apache2 -X -e debug") and see if anything gets printed to stderr. – David Z Jul 04 '09 at 04:52
  • As you mentioned there is no mention in the error logs, but try setting your `LogLevel` to `debug` and see if you can find anything. If not, we will need more information. – Ehtyar Jul 04 '09 at 05:00
  • @theotherreceive as I said, no, no errors. – Pablo Jul 04 '09 at 12:33

3 Answers3

2

It was a PHP error. Enabling display of PHP errors showed that and the reason why I didn't saw it when I was running the script manually is because I was running it as root and the error was lack of permission to write temporary data in a directory.

Pablo
  • 7,249
  • 25
  • 68
  • 83
  • Could you please share with us how you exactly enabled the displaying of the PHP errors and where they showed up? – Flow Apr 13 '11 at 09:04
  • @Flow, I don't remember exactly, thankfully, I don't work much with PHP. Here's the relevant documentation I believe: http://php.net/manual/en/errorfunc.configuration.php – Pablo Apr 13 '11 at 12:51
  • beware that if code uses `@` to suppress errors per-line, no change to php.ini can help you. see the Big Red Warning at http://php.net/manual/en/language.operators.errorcontrol.php – rymo Jun 21 '12 at 06:26
1

Make sure there is no .htaccess file in the folder path up to php file. That is if path is /var/www/html/a/b/test.php. Make sure there is no .htacces file in either /var/www/html, /var/www/html/a, /var/www/html/a/b folders. If there are .htaccess files, then rename them to something else and try again.

Most of the time I get 500 errors due to bad .htaccess file and since then do not show on simple 'ls', it is hard to understand that they are the source of problem.

Saurabh Barjatiya
  • 4,643
  • 2
  • 29
  • 34
0

Are you invoking PHP through libapache2-mod-php (mod_php) or through something like FastCGI? Please can you let us know the versions you have installed, your distribution, check the file/directory permissions and try;

tail -f /var/log/apache2/access.log /var/log/apache2/error.log

Or alter to suit if your logs are in a different location. Then try hitting the site with your browser, also what do you get from putting together 'test.php' with:

<?php
  phpinfo();
?>

Does it display a page properly?

nixgeek
  • 874
  • 5
  • 14