500 Internal Server Error is a common, irritating HTTP error in Opencart systems.
It’s clear that something has turned out badly.
But, what happened exactly? And, why has it happened?
At Bobcares, we help website owners to solve such complex website errors as part of our Server Management services.
Today, let’s discuss the top 5 reasons for this error and how we fix it.
But, before that, let’s get an idea of 500 internal server error.
What is ‘500 internal server error’ in Opencart system?
500 internal server error is a generic web server error message and should be commonly seen after Opencart migration.
In other words, it means that some error has occurred while accessing a page, but there are no details of what the error is or how to recover from it.
For instance, Opencart website owners usually see a 500 internal server error in their browsers like this:
As the first step to find a solution, our Hosting Engineers enable error reporting to display PHP parse errors on the website.
For example, in Opencart systems, we disable Output Compression level and enable display errors in the index.php file by adding the below code.
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
If that doesn’t work, we add these codes to the php.ini file.
And, then we get a more detailed explanation of the reason for this error.
Now, let’s discuss the top 9 reasons for this error and how we fix it.
500 internal server error in Opencart system – Causes & Fixes
In our experience managing websites, we’ll see the major causes of this error and how we fix it.
1) Wrong file or folder permissions
Servers with SuPHP or FastCGI enabled are sensitive to file and folder permissions.
The ideal file permissions are 644 and folders are 755.
Sometimes, 500 internal server errors can be caused by incorrect permissions of Opencart files or folders.
How we fix?
Our Hosting Engineers, check the Opencart website error logs first.
And, if any permission related errors are noted, we’ll immediately correct them.
Since, manually changing each file permission is a tedious task, we use custom scripts to change permissions.
For example, we use the below scripts to change the directory permission to 755, and file permission to 644.
find /home/USERNAME/public_html -type d -exec chmod 755 {} \;
find /home/USERNAME/public_html -type f -exec chmod 644 {} \;
Here /home/USERNAME/public_html is the path of the web directory.
In addition to that, we ensure that we take a backup of the website files before making any changes.
[Are you confused about resetting the file and folder permissions? Our Opencart Experts can help you. We are online 24/7.]
2) Low PHP Memory limit
The most common reason we’ve seen for 500 internal server error in Opencart websites is low PHP memory limit.
This error occurs when there is not enough memory to run the PHP script.
Most of the web hosting providers set the default memory_limit as 20MB, 32MB, 64MB, etc. and this works well for most store listing products.
But, if you want to list about 10,000 products at a time, the PHP memory limit will not allow this and result in 500 internal server error.
So, a sensible memory allocation is 256 MB.
How we fix?
Our Hosting Engineers use many ways to increase the PHP memory_limit on websites.
For example, in cPanel servers, we increase the memory_limit from cPanel > Select PHP version > Switch to PHP options > PHP selector.
Likewise, in some servers, we increase the PHP memory limit by adding the below code in the .htaccess file.
php_value memory_limit 256M
[If you are not sure of managing the resource limits allocated for your account? Our Support Experts are here for your help]
3) Misconfigured .htaccess
Similarly, another common cause of this error is the misconfigured .htaccess file.
Syntax errors, URL rewrite errors, typo errors, etc. in .htaccess file can lead to 500 internal server errors.
How we fix?
Our Support Engineers first check whether the .htaccess file is the actual culprit by renaming this file temporarily.
If any issues are noted, we locate and correct the misconfiguration in the .htaccess file.
In addition to that, we ensure that the .htaccess file is properly structured and configured.
4) Missing PHP modules
Another common reason for 500 internal server error in Opencart websites is the lack of required PHP modules.
For Opencart systems to work properly, modules such as Curl, Zip, Zlib, GD, Mcrypt, Mbstring, Xml are required.
How we fix?
Our Support Engineers check whether the required PHP modules are enabled with the phpinfo.php file.
And, if we find any modules missing, we either enable or install them for the domain.
Also, we always make sure to delete the phpinfo.php file after testing, because hackers can target it and misuse it.
Installing PHP modules is a technical task. If you are not confident, don’t go for it.
[If you suspect missing PHP modules are in your server, our Expert Engineers can fix it for you within minutes.]
5) PHP Timeout
Most web hosts set the default PHP time limit to 30 sec, 60 sec or 90sec.
A PHP timeout occurs when an Opencart application or a PHP request takes longer time to produce the output and terminates.
As a result, the website returns 500 internal server error.
How we fix?
In such cases, our Hosting Engineers tweak the timeout values so that script doesn’t timeout, but waits for the request to be processed.
For instance, in some servers, we tweak the PHP parameter max_execution_time in the file “php.ini” to increase the PHP timeout value.
max_execution_time = 300;
In cPanel servers, we change the max_execution_time value from cPanel > Select PHP version > Switch to PHP options > PHP selector.
However, increasing the PHP timeout limit is a complex process.
Because, higher timeout values are favorable for hackers to execute long running scripts in parallel to bring your web server down.
So, we first analyze the server resources and tweak these limits to optimal values.
6) Non-compatible Opencart extensions
Opencart extensions are addon programs that provide extra functionality to your website.
But, some extensions may not compatible with your Opencart version, or these files may be corrupted or not uploaded properly.
As a result, Opencart users see 500 internal server error.
For example, one such error is given below:
– Fatal error: Call to undefined method Customer::isLogged() in /path/public_html/catalog/model/catalog/product.php on line 8;
How we fix?
To check the compatibility, we disable all extensions and enable them one by one to identify the culprit.
If our Hosting Engineers find a corrupted extension, we download a fresh copy and re-upload the files once again.
[If you’re unable to find which extension caused this error, our Opencart support team can fix it for you. We’re available 24/7]
7) vQmod and oCmod permissions
vQmod helps Opencart developers to have 3rd party extensions that require Opencart core modifications without affecting the integrity of core system files.
And, oCmod is the simplified vQmod version.
But, we have seen cases where vQmod or oCmod fails to generate cache from vQmod file extensions.
As a result, the website throws 500 internal server error.
How we fix?
Our Hosting Engineers check the permission of the folders “vqmod/cache” and “/system/storage/modification/” and make sure they are writable.
Moreover, we manually clear the vQmod cache and the oCmod cache to fix the issue.
8) Corrupted files or wrong encoding
Many Opencart owners approach us saying their website broke after modifying or updating Opencart files.
We’ve seen that, such problems often happen due to incorrect encoding or stray spaces inserted in the files.
How we fix?
If you are not an expert, we always suggest to download a fresh copy of Opencart files and replace the recently changed files.
If extensive changes are made to the Opencart files, our Hosting engineers manually check the files and fix syntax errors.
Additionally, we ensure that proper encoding is set for the Opencart files.
[If you are not a coding expert to fix this problem. Don’t worry, We can do it for you in a few minutes.]
9) Security restriction in the server
Similarly, we’ve seen Opencart website don’t work when script execution is blocked by a firewall like mod_security or a PHP restriction in effect.
The result is website throwing 500 internal server error.
How we fix?
If we find that the website is blocked by mod_security, we identify which security rule has been triggered and add an exemption for that site.
Similarly, in case of safe_mode restriction enabled in PHP, we exclude the domain from this restriction by adding the below code in .htaccess file.
php_value safe_mode off
This list is not complete. There could be many more reasons for this error to occur.
But, we have to do a detailed log analysis to identify the problem.
So, if you need help, click here for an Opencart expert to look into your site. We are online 24/7.
Conclusion
In short, 500 internal server error in Opencart systems are quite annoying. This can happen due to .htaccess errors, resource limits and more. Today, we’ve shared the top 9 reasons for this error and how our Dedicated Support Engineers fix it.
0 Comments