Internal Error 500 Apache, but nothing in the logs?

后端 未结 11 534
失恋的感觉
失恋的感觉 2020-11-27 14:36

I\'m getting 500 Internal Server errors when I try to make an HTTP POST to a specific address in my app. I\'ve looked into the server logs in the custom log directory speci

相关标签:
11条回答
  • 2020-11-27 14:46

    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.

    0 讨论(0)
  • 2020-11-27 14:46

    Please check if you are disable error reporting somewhere in your code.

    There was a place in my code where I have disabled it, so I added the debug code after it:

    require_once("inc/req.php");   <-- Error reporting is disabled here
    
    // overwrite it
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    
    0 讨论(0)
  • 2020-11-27 14:48

    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.

    0 讨论(0)
  • 2020-11-27 14:50

    Please Note: The original poster was not specifically asking about PHP. All the php centric answers make large assumptions not relevant to the actual question.

    The default error log as opposed to the scripts error logs usually has the (more) specific error. often it will be permissions denied or even an interpreter that can't be found.

    This means the fault almost always lies with your script. e.g you uploaded a perl script but didnt give it execute permissions? or perhaps it was corrupted in a linux environment if you write the script in windows and then upload it to the server without the line endings being converted you will get this error.

    in perl if you forget

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

    you will get this error

    There are many reasons for it. so please first check your error log and then provide some more information.

    The default error log is often in /var/log/httpd/error_log or /var/log/apache2/error.log.

    The reason you look at the default error logs (as indicated above) is because errors don't always get posted into the custom error log as defined in the virtual host.

    Assumes linux and not necessarily perl

    0 讨论(0)
  • 2020-11-27 14:56

    The answers by @eric-leschinski is correct.

    But there is another case if your Server API is FPM/FastCGI (Default on Centos 8 or you can check use phpinfo() function)

    In this case:

    1. Run phpinfo() in a php file;
    2. Looking for Loaded Configuration File param to see where is config file for your PHP.
    3. Edit config file like @eric-leschinski 's answer.
    4. Check Server API param. If your server only use apache handle API -> restart apache. If your server use php-fpm you must restart php-fpm service

      systemctl restart php-fpm

      Check the log file in php-fpm log folder. eg /var/log/php-fpm/www-error.log

    0 讨论(0)
  • 2020-11-27 15:01

    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.

    0 讨论(0)
提交回复
热议问题