program story

내부 오류 500 Apache이지만 로그에 아무것도 없습니까?

inputbox 2020. 8. 12. 08:14
반응형

내부 오류 500 Apache이지만 로그에 아무것도 없습니까?


내 앱의 특정 주소로 HTTP POST를 수행하려고하면 500 개의 내부 서버 오류가 발생합니다. 가상 호스트 파일에 지정된 사용자 지정 로그 디렉터리에서 서버 로그를 조사했지만 오류가 표시되지 않으므로 디버깅하는 것은 엉덩이에 고통 스러웠습니다.

Apache가 내부 500 오류를 오류 로그에 기록하도록하려면 어떻게해야합니까?


스크립트 오류 로그와 반대로 기본 오류 로그에는 일반적으로 (더 많은) 특정 오류가 있습니다. 종종 권한이 거부되거나 심지어 찾을 수없는 통역사 일 수도 있습니다.

이것은 오류가 거의 항상 스크립트에 있음을 의미합니다. 예를 들어 펄 스크립트를 업로드했지만 실행 권한을 부여하지 않았습니까? 또는 Windows에서 스크립트를 작성한 다음 줄 끝이 변환되지 않고 서버에 업로드하면 Linux 환경에서 손상되었을 수 있습니다.이 오류가 발생합니다.

잊으면 펄에서

print "content-type: text/html\r\n\r\n";

이 오류가 발생합니다

그것에 대한 많은 이유가 있습니다. 따라서 먼저 오류 로그를 확인한 다음 추가 정보를 제공하십시오.

기본 오류 로그는 종종 /var/log/httpd/error_log또는에 /var/log/apache2/error.log있습니다.

기본 오류 로그 (위에 표시된대로)를 보는 이유는 오류가 가상 호스트에 정의 된대로 사용자 지정 오류 로그에 항상 게시되는 것은 아니기 때문입니다.

Linux를 가정하고 반드시 perl은 아닙니다.


500 개의 내부 서버 오류가 아파치 오류 로그에 기록되지 않는 이유는 무엇입니까?

500 내부 서버 오류를 일으키는 오류는 PHP 모듈에서 발생합니다. 기본적으로 PHP는 이러한 오류를 기록하지 않습니다. 웹 요청이 물리적으로 가능한 한 빨리 진행되기를 바라는 이유는 공격자가이를 관찰 할 수있는 화면에 오류를 기록하는 것이 보안 위험입니다.

내부 서버 오류 로깅을 활성화하기위한이 지침은 Ubuntu 12.10with PHP 5.3.10및에 대한 것 입니다 Apache/2.2.22.

PHP 로깅이 켜져 있는지 확인하십시오.

  1. php.ini 파일을 찾습니다.

    el@apollo:~$ locate php.ini
    /etc/php5/apache2/php.ini
    
  2. 해당 파일을 루트로 편집하십시오.

    sudo vi /etc/php5/apache2/php.ini
    
  3. php.ini에서 다음 줄을 찾으십시오.

    display_errors = Off
    
  4. 위의 줄을 다음과 같이 변경하십시오.

    display_errors = On
    
  5. 파일에서 아래로 내려 가면 다음이 표시됩니다.

    ;display_startup_errors
    ;   Default Value: Off
    ;   Development Value: On
    ;   Production Value: Off
    
    ;error_reporting
    ;   Default Value: E_ALL & ~E_NOTICE
    ;   Development Value: E_ALL | E_STRICT
    ;   Production Value: E_ALL & ~E_DEPRECATED
    
  6. 세미콜론은 주석이며, 이는 행이 적용되지 않음을 의미합니다. 해당 줄을 다음과 같이 변경하십시오.

    display_startup_errors = On
    ;   Default Value: Off
    ;   Development Value: On
    ;   Production Value: Off
    
    error_reporting = E_ALL
    ;   Default Value: E_ALL & ~E_NOTICE
    ;   Development Value: E_ALL | E_STRICT
    ;   Production Value: E_ALL & ~E_DEPRECATED
    

    What this communicates to PHP is that we want to log all these errors. Warning, there will be a large performance hit, so you don't want this enabled on production because logging takes work and work takes time, time costs money.

  7. Restarting PHP and Apache should apply the change.

  8. Do what you did to cause the 500 Internal Server error again, and check the log:

    vi /var/log/apache2/error.log
    
  9. You should see the 500 error at the end, something like this:

    [Wed Dec 11 01:00:40 2013] [error] [client 192.168.11.11] PHP Fatal error:  
    Call to undefined function Foobar\\byob\\penguin\\alert() in /yourproject/
    your_src/symfony/Controller/MessedUpController.php on line 249, referer: 
    https://nuclearreactor.com/abouttoblowup
    

Check your php error log which might be a separate file from your apache error log.

Find it by going to phpinfo() and check for error_log attribute. If it is not set. Set it: https://stackoverflow.com/a/12835262/445131

Maybe your post_max_size is too small for what you're trying to post, or one of the other max memory settings is too low.


I just ran into this and it was due to a mod_authnz_ldap misconfiguration in my .htaccess file. Absolutely nothing was being logged, but I kept getting a 500 error.

If you run into this particular issue, you can change the log level of mod_authnz_ldap like so:

LogLevel warn authnz_ldap_module:debug

That will use a log level of debug for mod_authnz_ldap but warn for everything else (https://httpd.apache.org/docs/2.4/en/mod/core.html#loglevel).


If your Internal Server Error information doesn't show up in log files, you probably need to restart the Apache service.

I've found that Apache 2.4 (at least on Windows platform) tends to stubbornly refuse to flush log files—instead, logged data remains in memory for quite a while. It's a good idea from the performance point of view but it can be confusing when developing.


Check that the version of php you're running matches your codebase. For example, your local environment may be running php 5.4 (and things run fine) and maybe you're testing your code on a new machine that has php 5.3 installed. If you are using 5.4 syntax such as [] for array() then you'll get the situation you described above.


Try accessing a static file. If this is not working either then go to all directories from the root "/" or "c:\" to the directory of your file and check if they contain ".htaccess" files.

I once left a file in "c:\" and it had the most strange results.


In my case it was the ErrorLog directive in httpd.conf. Just accidently noticed it already after I gave up. Decided to share the discovery ) Now I know where to find the 500-errors.


Add HttpProtocolOptions Unsafe to your apache config file and restart the apache server. It shows the error details.

참고URL : https://stackoverflow.com/questions/4731364/internal-error-500-apache-but-nothing-in-the-logs

반응형