php Apache 500 服务器错误 - 日志不显示任何内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9429616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:47:48  来源:igfitidea点击:

Apache 500 server error- logs showing nothing

phpapache

提问by Lock

Just after some help with a new installation of PHP.

在新安装 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/.

我已经用 apache PHP 设置了一个新的 Centos 6.2 服务器,但在显示错误时遇到了麻烦。我已经从不同的文件夹结构以及 /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:

当我访问我的网站时,出现 500 错误或空白页面。除了记录 500 错误之外,日志根本没有显示任何内容:

[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

我的 htaccess 看起来像这样: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.

并且 php.ini 将 error_reporting 设置为 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?

所以我想我的问题是 - 如何开始调试 500 服务器错误?

回答by Bob Stein

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:

当错误消息从屏幕、Apache error_log 文件和其他任何地方令人发狂地丢失时,我很幸运通过添加不同的 PHP 文件让它们出现,仅将其用于开发:

<?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.

这样,即使 productioncode.php 有编译时错误,上面的代码也会运行,并显示消息,而不是仅仅将前两行放在 productioncode.php 的顶部。

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

@Jaspreet Chahal 和 @Saiyam Patel - 我刚刚从 access_log 中错误 500 的美好夜晚中恢复过来,例如

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.

并且在任何 httpd 日志文件中都没有 PHP 错误消息(愚蠢地)编码 { 'foo' => 'bar' } 而不是 array( 'foo' => 'bar' )。使用上述技术揭示了详细的错误消息,包括非常重要的行号。

回答by Saiyam Patel

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

Apache 500 服务器错误这不是 PHP 错误这是服务器错误(服务器无法处理您的请求)或者可能是 .htaccess 文件有问题,可能是重定向

cheers

干杯

回答by Jaspreet Chahal

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/httpdand check for error_logfile. if its a custom log then search for that file.

只需尝试从您的配置文件中检查存储日志的位置。我猜你显示的是访问日志而不是错误日志。所以只需检查错误日志存储在哪里。干杯! 正如你所说,它的centos 检查这个目录/var/logs/httpd并检查error_log文件。如果它是自定义日志,则搜索该文件。

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

顺便说一句,500 是服务器错误,所以对我来说,我认为它必须与您的配置或数据库连接设置有关。