仅在htaccess中启用PHP中的错误显示

问题描述

| 我正在在线测试一个网站。 目前,错误尚未显示(但我知道它们存在)。 我只能访问
.htaccess
文件。 如何使用
.htaccess
文件显示所有错误? 我将这些行添加到了我的
.htaccess
文件中:
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
现在页面显示:   内部服务器错误     

解决方法

.htaccess:
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log
    ,
php_flag display_errors on
打开错误的实际显示。 要设置显示的错误类型,您将需要使用:
php_value error_reporting <integer>
结合以下页面中的整数值:http://php.net/manual/zh/errorfunc.constants.php 请注意,如果您对整数使用-1,它将显示所有错误,并且当它们添加新的错误类型时可以用作将来的证明。     ,我想在现有答案中添加更多详细信息:
# PHP error handling for development servers
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /full/path/to/file/php_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0
向日志文件授予777或755权限,然后添加代码
<Files php_errors.log>
     Order allow,deny
     Deny from all
     Satisfy All
</Files>
在.htaccess的末尾。 这将保护您的日志文件。 这些选项适用于开发服务器。对于生产服务器,您不应向最终用户显示任何错误。因此,将显示标志更改为关闭。 有关更多信息,请单击此链接:通过htaccess的高级PHP错误处理     ,如果只想看到致命的运行时错误:
php_value display_errors on
php_value error_reporting 4
    ,这对我有用
# PHP error handling for production servers
# disable display of startup errors
php_flag display_startup_errors off

# disable display of all other errors
php_flag display_errors off

# disable html markup of errors
php_flag html_errors off

# enable logging of errors
php_flag log_errors on

# disable ignoring of repeat errors
php_flag ignore_repeated_errors off

# disable ignoring of unique source errors
php_flag ignore_repeated_source off

# enable logging of php memory leaks
php_flag report_memleaks on

# preserve most recent error via php_errormsg
php_flag track_errors on

# disable formatting of error reference links
php_value docref_root 0

# disable formatting of error reference links
php_value docref_ext 0

# specify path to php error log
php_value error_log /home/path/public_html/domain/PHP_errors.log

# specify recording of all php errors
# [see footnote 3] # php_value error_reporting 999999999
php_value error_reporting -1

# disable max error string length
php_value log_errors_max_len 0

# protect error log by preventing public access
<Files PHP_errors.log>
 Order allow,deny
 Deny from all
 Satisfy All
</Files>
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...