Google guides me here but it didn't fix mine, this is a very general question and there are various causes, so I post my problem and solution here for reference in case anyone might read this later.
Another possible cause of 500 error is syntax error in header(...)
function, like this one:
header($_SERVER['SERVER_PROTOCOL'] . '200 OK');
Be aware there should be space between server protocol and status code, so it should be:
header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
So I suggest check your http header call if you have it in your code.