欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

php 服务器500错误解决 定位 查看 显示 提示 出现 排查 在哪里 自己亲自做的 有大用 有大大用 有大大大用

为什么要关掉 drupachat 模块 才起作用

如果下面的方法实在不行的话,我们就 开始 nginx apache 的日志功能 ,查看 access.log 和 access_log

drupal drupal7 d7  中 /admin/config/development/logging

image.png



drupal 中,添加了下面的代码, 要清空缓存, 运行cron再试试看

<?php
// $Id: index.php,v 1.94 2007/12/26 08:46:48 dries Exp $

/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* The routines here dispatch control to the appropriate handler, which then
* prints the appropriate page.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*/
 error_reporting(E_ALL);
 ini_set("log_errors", 1);
 ini_set("error_log", "php_error.log");
 ini_set('display_errors', TRUE);
 ini_set('display_startup_errors', TRUE);

require_once './includes/bootstrap.inc';
//if($_GET['q']=='admin/user/user/list'){
//  $start0 = microtime();
//}
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
//cache_clear_all();
//drupal_flush_all_caches();
//drupal_cron_run();
//var_dump("CCCCC");exit;
$return = menu_execute_active_handler();


image.png





error_reporting(-1); // reports all errors

error_reporting(E_ALL); // reports all errors 最好使用 E_ALL 不使用 -1

ini_set("display_errors", "1"); // shows all errors

ini_set("display_start_errors", "1"); // shows all errors   // "display_startup_errors"

ini_set("log_errors", 1);

//ini_set("error_log", "/tmp/php-error.log"); 是不是 /tmp目录下,php没有访问权限的问题

ini_set("error_log", "php-error.log"); 

不知什么原因 在 php里设置好像不行(又好像是行的) 好像必须在 php.ini 文件里(设置display_errors,然后重启服务器)

log_errors = On

error_log = php_errors.log

 (至少199服务器是这样子的 修改的是 /www/wdlinux/php/etc/php.ini  )

记住  199  运行的 php 在这儿


image.png




我在 199 服务器的  php.ini上面  下面的设置就会 

使错误出现在页面上以及出现在 php_errors.log 里面

 有大用 有大大用 有大大大用

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

display_errors = On

display_startup_errors = On

log_errors = On

error_log = php_errors.log






访问php网站报500错误时显示错误显示

感觉只要下面的两行代码就可以有错误日志了 有大用 有大大用 有大大大用 有大大大大用 有大大大大大用
ini_set
("log_errors", "on");
ini_set("error_log", "php_erroraaaaaaa.log");



感觉只要下面的两行代码就可以把错误显示在页面上了
error_reporting(E_ALL);
ini_set("display_errors", "1"); // shows all errors



调试时可在访问的php文件开头输入

1
2

ini_set("display_errors""On");

ini_set("display_startup_errors""On");

error_reporting(E_ALL | E_STRICT);

这样就会在页面上显示具体的php错误

来自 https://www.cnblogs.com/ailhc/p/6586429.html  


 php 新手在初期搭建完开发环境后,开发时出现语法错误时,服务器返回500 ( 服务器内部错误),而不是返回错误提示。 这时候需要对开发环境做一些配置,帮助你快速查找问题原因,定位问题,解决问题。

   找到 php的配置文件  /etc/php.ini 

    配置参数值:display_errors = On 

 error_reporting = E_ALL | E_STRICT

  重启apache 服务  service  httpd  restart 

  这个时候 浏览器已经可以输出错误信息了。


  需要再配置下 apache    /etc/httpd/conf/httpd.conf

 在 apache的配置文件最后添加 两行:


php_flag display_errors on
php_value error_reporting 2039 


重启apache。



对php.ini 中参数的设置 也可用在php代码中完成。

调用:调用ini_set()函数

//开启php.ini中的display_errors指令
ini_set('display_errors',1);


//通过error_reporting()函数设置,输出所有级别的错误报告
error_reporting(E_ALL);

这样可用动态的,在指定的php文件中,输出错误。


来自 http://blog.csdn.net/googlg/article/details/52814387



普通分类: