If there is an internal error, the first step is to view the log files. For Linux servers, the collection of error messages should be found at /var/log/httpd/error_log. It makes sense to reload the website to reproduce the HTTP error 500 code and observe how the log file is being created. This will help you find the source of the error quite quickly. Also consider which changes were made shortly before. In many cases, incorrectly programmed or incompatible plugins are the cause of error messages.
Errors can also occur if you have not set permissions correctly for important files. In general, there are three types of rights:
Read (r)
Write (w)
Execute (x)
These permissions can be assigned for three different user types:
Owner of the file
Group of users
All others
The rights are specified either in the abbreviations r, w, and x, or in corresponding numerical values: 4 for read, 2 for write, and 1 for execute. They are added for each user type and specified one after the other: rwxr-xr-x (rwx for the owner, r-x for the group, and r-x for all others) or 755. This configuration (755) should be the default setting. If the permission assignment is set differently, an error may occur. You can change this with a command:
chmod 755 filename
If this change does not solve the problem, you can also release all rights for each group for test purposes:
chmod 777 filename
But only use this setting to locate the problem. Any user is allowed to rewrite the file, which is understandably a security risk.
Next, check (if distributing the rights didn’t produce the error message) if your scripts are running correctly. Sometimes errors occur because the script files have been moved, renamed, or deleted. Also check the .htaccess file: even a syntax error – no matter how small – can cause an internal server error. An equally common error is incorrectly formatting the .htaccess file. This must be created in ASCII or ANSI format, not in Unicode. Therefore, write the file in a text editor such as Notepad, Notepad++, or Sublime Text, and not in a word processing program such as Microsoft Word. To test whether the file is responsible for the error, you can temporarily rename it and reload the website. The server now won’t access .htaccess when loading the website. If you no longer receive the error message, you can repair the file or create a new one.
A timeout can also lead to an error message. In this case, it isn’t a web server error, but rather an interrupted connection to an external source. Are PHP scripts on your website set to access resources from other servers? Perhaps the resource is no longer available or server communication is down for some other reason. One way to eliminate this source of error is of course to not make your site dependent on external resources. If this is not possible, you can increase the time limit of your script. It also makes sense to implement efficient error handling so that errors in the PHP script can be detected more accurately.
Could it be that the memory is overloaded? The memory limit determines how much memory a process may use. If more RAM is needed than is available, this could result in an internal server error. You can increase the limit as a temporary solution. To do this, add a command like this to php.ini:
memory_limit = 512M
In this example, you would set the memory provided to 512MB. Note, however, that your hosting provider will only allow you a certain PHP script limit within the package that you’ve booked. If you enter a higher value, the web server will ignore it. Raising the limit is only a temporary solution: once your site is up and running again, you should look for the reason for the high RAM usage. There is a high probability that the error can be found in the code of your website.
If none of these methods offer you a solution, it is a good idea to contact your hosting provider. Before doing so, you can check the status of the servers: many hosting service providers will report the status of their servers via a status page or inform users via social media if a problem has occurred.
Source: https://www.ionos.com/digitalguide/hosting/technical-matters/http-error-500-internal-server-error/
https://realesaletter.com
https://www.lifewire.com/500-internal-server-error-explained-2622938
https://www.interserver.net/tips/kb/troubleshoot-500-internal-server-error/