If you are facing 500 Internal Server Error for your WordPress after migration from one server to another, some may blame the Web Hosting and some the .htaccess. Unfortunately, most does not tries understand a major point – one blog which was active without any 500 Internal Server Error, without some code change it will not show 500 Internal Server Error. Such changes may happen “automatically”, like changes created by a plugin’s auto-update.
Understanding why 500 Internal Server Error occurs in WordPress after the migration
Most of us simply copy-paste the whole …/public folder content either through FTP or Tar it, download to the new server using the Shell and untar it, restore the MySQL database from the old to the new, change the name-server (s) and do. Three steps, for a good host like Rackspace, everything takes hardly a day. Then why do we face this 500 Internal Server Error?
500 Internal Server Error can happen in the following cases :
Corrupted .htaccess – In this case 500 Internal Server Error will happen ALWAYS, not randomly.
File Permission Problem – Unusual for server migrations, you have to CHMOD to change the file permissions, you will get the default file and folder permissions in WordPress codex.
Less allocated PHP memory/default PHP memory – This is the commonest and almost always “undiagnosed” reason for random 500 Internal Server Error after server migration.
What is random 500 Internal Server Error ?
Your website or blog opens rightly at one moment and at the next moment when you try to open the XYZ page or post sudden it shows a 500 Internal Server Error. If you refresh the page, it loads rightly again.
Fixes for the 500 Internal Server Error
Corrupted .htaccess – Try with “default” clean .htaccess file. I have kept default within quotation marks as, unless permalink structure is activated, WordPress needs no .htaccess. Random 500 Internal Server Error is very less likely to happen with a corrupted .htaccess file.
File Permission Problem – Either CHMOD from the shell or right-click on your sFTP / FTP to change the file permissions.
Less allocated PHP memory/default PHP memory – I will suggest starting with this diagnostic approach for fixing the 500 Internal Server Error. Most probably, you have not increased the PHP memory with your old server from .htaccess or wp-config. Almost always we forget to change the limit from php.ini (if have access) or the previous hosting provider had configured a higher PHP memory.
To diagnose precisely why this 500 Internal Server Error is occurring, you need access to the error log file, which can be under a folder named log (depends on the Linux Distro and Virtualization Switch). For Rackspace, you will find it under :
root/www.name-of-your-website-showing-500 Internal Server Error.com/logs/php_error.log
PHP memory is by default 32 MB, which is practically nothing if you are using XML Sitemap generator, some SEO Plugins etc. and you have around 2K posts, the PHP memory will simply be exhausted and throw 500 Internal Server Error.
Simply look if anything is saying “memory limit exceeded allocated…”; this is the root cause of 500 Internal Server Error. It is not those plugins responsible for 500 Internal Server Error directly, but the limit of PHP memory is calling the 500 Internal Server Error to happen and you can easily fix it through .htacess and/or wp-config file.
For Rackspace, there is no limit up to what you can increase this PHP memory. There will be no limit for the Cloud Servers who calculates the consumption as Computing Cycles. You can increase to a few GB (you have to mention MB).
In order to increase the php memory, to get rid of random 500 Internal Server Error, you can add this to your .htaccess file (in the root) :
php_value memory_limit valueM
Change the word value to to your desired value.
Importance: It solves the random 500 Internal Server Error due to insufficient PHP memory. This value of PHP memory is distributed for all the files under the folder (the root of your website in this case) including WordPress. If you have a subdomain, that will share it and might throw 500 Internal Server Error as the memory has not increased much in real. For example, in your main folder, there is WordPress (default PHP memory 32 MB) and in sub- there is another WordPress (32 MB again), if you increase the PHP memory to 64 MB from the .htacees in the root of your website, you will get 500 Internal Server Error again! Simply because the 64 MB is divided into 2 x 32 MB. So to solve this 500 Internal Server Error in your case you will need a value of more than 64 MB.
Changing PHP memory from wp-config to solve the random 500 Internal Server Error :
in wp-config.php, you need to add :
Change the word value to to your desired value.
Importance: This is specific for the WordPress installation under question showing random 500 Internal Server Error.
Changing from php.ini: It is better to ask the hosting provider before manipulating php.ini.
More on random 500 Internal Server Error
If increasing the memory to practical value does not solve the 500 Internal Server Error, there is a probable issue with the SQL database (as we are talking about migration). Again, look what error is showing on the error log. If the 500 Internal Server error is due to any specific plugin, deactivate, delete it, clean the database and then install the plugin again. You will not get 500 Internal Server Error anymore.
Sometimes, hacking attempts can throw 500 Internal Server Error. This is due to the fact, the hacker has injected some code and that is eating up the PHP memory. PHP log will show the problem.Tagged With wordpress 500 internal server error , WordPress Error 500 , wordpress 500 error , 500 internal server error wordpress , internal server error 500 , 500 internal server error after editing htaccess , wordpress 500 internal error , wordpress http 500 error , wordpress internal server error , wordpress copy database error 500