Since many of you are probably looking for an immediate solution to the problem I will post my solution first.

The Cure

Let’s dive right in. First thing you should probably do is check your error logs (i.e., your apache error logs). If your error logs aren’t giving you any strong hints then try some of the solutions listed below.

MySQL - Bad plugins

Executing the following SQL statement will disable all plugins. If this fixes your problem, you will be able to log back into Wordpress and enable plugins one by one til you find the issue.

update wp_options set option_value='a:0:{}' where option_name = 'active_plugins';

For me this fixed it. I had my doubts about this working in general, but I tried it anyway and it worked, it turns out that one of my plugins was failing (even though it was working on my previous hosting and my local environment)

Once the plugins have all been disabled via the query above, it is safe to attempt toggling them on one by one, as Wordpress seems to have some sort of built-in security for testing out the modules and disabling them immediately if they cause any errors to occur.

.htaccess

.htaccess is another common offender of 500 errors. You can try disabling the .htaccess file by simply renaming it to something else (i.e., .htaccess-off). If this works, then you have to turn it back on and figure out what’s causing the issue inside of the .htaccess.

When performing a move of a wordpress blog from one server to another I checked my apache logs and noticed that apache was having issues with the RewriteRule directives in my .htaccess file. I got the following message in my error log:

Invalid command 'RewriteRule', perhaps misspelled or defined by a module not included in the server configuration

This was a friendly reminder that I forgot to enable apache’s mod_rewrite. On a default ubuntu server setup you can use the a2enmod utility for enabling apache2 modules:

a2enmod rewrite

File permissions

I’ve also been told that file permissions could be the cause of this. I’m not sure that file permissions had any part in my issues specifically, but clean permissions are always a good idea.

This is especially helpful if you have shell access to your web hosting. A lot of shared hosting companies do provide ssh access, sometimes you have to just submit a special request ticket to support.

Here’s what you want to check: - Proper ownership of files. Files should be owned by the appropriate user for apache. A user like www-data or perhaps your own user name in a shared hosting setup. - Proper file permissions. File permissions can be reset using the find utility:

find /path/to/wordpress -type f -exec chmod 644 {} \;
find /path/to/wordpress -type d -exec chmod 755 {} \;

The above is a commonly used set of find commands to reset file permissions to their defaults.

What is WSOD? What’s a 500 Error?

I gave a few tips about how to fix the White Screen of Death and the 500 errors, but what are they?

WSOD.

First the WSOD. The White Screen of Death is a common term used on the web to describe when you try to access your site and all you see is a blank white page. This is caused by a combination of different things.

The first part of this problem is that there is an error somewhere in your code. The second part of the problem is that your error reporting is silenced on the front end. Surpressing errors from displaying on your website is recommended for production websites, but it can leave you confused if you don’t know to expect the white screen when something blows up. This same behavior can be seen in almost any web application, not just Wordpress.

If the errors aren’t showing on the frontend—and they shouldn’t in production—the errors will be available via the log files I was talking about earlier. On most linux setups I believe the logs should be in /var/log/apache2/ depending on your configuration, however, the log files could be anywhere.

500 Error

I was poking around the Wordpress forums to see what people were doing to fix 500 errors, and I really couldn’t find anything. For those who do not know, 500 errors typically look like this: 500 error

What I did find, however, was a common misconception of what a 500 error is. I believe one person stated it as being the result of exceeding your bandwidth on your web host, which is more than likely not the problem most of the time.In fact, I’m not even sure if that’s possible for it to be the issue.

The bottom line is this: A random error has occurred, it could be anything. It’s usually something to do with the web server—like an apache or php module that has not been enabled or configured properly—or the code that it is running—in our case the PHP code from wordpress or one of its pluginsns.


blog comments powered by Disqus

Published

04 April 2013

Tags