How to fix the internal server error 500 or blank page
First of all, what are these internal server errors or 500 errors? When you encounter this error, you should know that it doesn’t say exactly what is happening, it’s only saying that the server encountered an internal error and failed to return an result. These type of errors are also called generic errors. How to fix the internal error 500 is really simple in most cases. Usually you encounter this generic error when you have php errors, when there’s a bad .htaccess rule or when there are permission issues with your files.
-
Fix php errors
To fix a php error you first need to see the exact error. Seeing only the 500 internal error clearly doesn’t help you resolve this issue. In such cases you need to either enable php logging to log your php errors into a file, or enable display errors in your php configuration.
Currently most cPanel hosting provider uses suPHP with suexec as a php handler due to its security settings it has. While it slows down the performance by using more CPU, it ads multiple security options like permissions and ownership for php files.
But that’s not what I want to say, most cPanel providers that uses suPHP with suexec as a php handler allows you to use a custom php.ini to change the php configurations. So you just login to your FTP account or use File Manager to login into your account, navigate to your website document root and create there a simple php.ini file.
Then add the following lines to your php.ini:
1 |
display_errors = on |
This will enable display errors in your browser and should show you what the php errors is and allow you come up with a solution.
On other servers however you probably need to set the following line into your .htaccess file:
1 |
php_value display_errors on |
This in turn will enable display errors and will allow you to see the php errors in your browser.
Another option to see the php errors in case apache error log is enabled and you have access to the server is ti tail the server error log. This will show you the exact error for the 500 internal error.
-
Fix .htaccess errors
These errors however are a little tricky, I can’t say how exactly you can fix an issue since the complexity level here is a little higher and really depends on the rewrite rules you created, the script and so on. So without seeing the exact rules there really isn’t a “fix all issues” for this.
What you can do, is check if the internal error is because of your .htaccess rules. You can easily do this by either checking the server error_log or by renaming the .htaccess file to something else. If the website will work after renaming the .htaccess file or shows other issues it can be because of the .htaccess rules. The error_log howerver provides a more exact answer and will let you know if the rules are wrong or if the .htaccess permission is wrong.
-
Fix php files permission errors
As I said before, php errors can also be caused due to invalid permissions. While this being the cause, your php error_log should indicate which files have incorrect permission. Then to fix the error you should set the permission as follow:
- 644 – for normal files
- 444 – for configuration or settings files
- 755 – for folders
To set the permission you can either use your control panel Filemanager or use a FTP client like Filezilla.
These 3 issues happen in most internal errors, and these are the first you should check. PHP errors can be resolved easily if you know what is wrong, permission errors the same, the tricky part is the .htaccess rules which you need knowledge to check and fix them.