[php] 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/en/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>


답변