WordPress 500 Error

Computing

WordPress 500 Error

I’ve been getting random crashes with WordPress of late with an error of 500 showing up in my browser header and the web page displaying the text shown below. I am hosted with GoDaddy so this may be specific to them but have a read you may find it works on your host.

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.33 Server at www.aaronrockey.com Port 80


The Wikipedia HTTP status codes page lists the 500 error as this

“500 Internal Server Error – A generic error message, given when no more specific message is suitable”

Well that didn’t really tell me much!…

After getting no joy from Wiki, I did some more digging via Google, what I found was a lot of people had the same error and quite a few had GoDaddy hosting which I also have.

This is the long post about it over at WordPress.org forum, I feel sorry for the poor GoDaddy rep who had to deal with all those uphappy people!

One fix I found said to create a php.ini file in your wp-admin folder and add this to it memory=20MB

The error mentioned looking at your log files so I went to do just that, however looking around the directory via Filezilla FTP I couldn’t see any so I thought it must be available through the GoDaddy site.

This page tells you what to do to work with error logs at GoDaddy.

In your GoDaddy Hosting Control Center under settings click the Error Logs icon.

pic Error Log Button in GoDaddy's Hosting Control Center

Error log button

You need to enable the logging first, to do that you click the update button. Your page will look slightly different than this as I’ve already enabled my logging.

pic Enable Logging with GoDaddy

Enable error logging

If your lucky like I was once I enabled this and went back to my site and started looking around it crashed, to access the logs go back into the Hosting Control Center and from the Content Tab click FTP Manager or the big FTP button.

pic GoDaddy FTP Manager

FTP Manager

pic FTP File Manager Button

Big FTP Button

Once you’re in the File Manager area you will see the error logs section click on the folder which will open it, find the error log if any and click the download button and take a look at it.

pic Error Logs

Error Logs

In this pic the error log is zero bytes plus there is another file there, check each file you have in this folder that isn’t zero bytes.

pic The Error Logs

The actual error logs

The errors I got were all related to Fast CGI, I removed the IP numbers and the full address from the below.

[Thu Apr  7 18:56:28 2011] [error] [client 00.00.000.00] FastCGI: invalid (dynamic) server “/var/chroot/home/content/html-x-httpd-php5″: script not found or unable to stat()
[Thu Apr  7 18:56:28 2011] [error] [client 00.00.000.00] FastCGI: invalid (dynamic) server “/var/chroot/home/content/html-x-httpd-php5″: script not found or unable to stat()
[Thu Apr  7 18:56:28 2011] [error] [client 00.00.000.00] FastCGI: invalid (dynamic) server

I did have issues trying to download the error log with Firefox 4 so had to use Internet Explorer.

I rang GoDaddy support and told the rep about the error, he pointed to back to the menu under Settings – File Extension Management and changed the PHP settings from PHP FastCGI to just PHP so PHP 5 Fast CGI became PHP 5. You tick the check box and then click the edit icon at the end of the line.

pic File Extension Management

File Extension Management

pic Change Fast CGI

Change PHP Fast CGI to PHP

I’ve not seen any 500 errors since, fingers crossed!

Other Causes of the 500 error

I’ve been playing around with various plug-ins lately installing them and then if I didn’t like them un-installing them, I get the feeling WordPress is a bit soft around the edges and doesn’t like it if you install and un-install things too often.

I also changed my Permalinks to “pretty” ones like www.aaronrockey.com/wordpress-500-error instead of the default “ugly” ones http://www.aaronrockey.com/?p=123

I’ve been fixing my posts to make them more SEO friendly and sometimes I’ve fixed the original post Permalink. After doing some reading online I’ve found out that you may get mod-rewrite errors which can cause the 500 errors, one fix is to go back to the default Permalink setting save it and then go back to your modified setting which apparently forces a rewrite of your .htaccess file.

Other diagnostic check are to rename the .htcaccess file or delete it via FTP and see if the error still occurs.

I also found something very interesting which may explain a lot why my site seems to be slow sometimes.

At WordPress.org I came across this little snippit.

http://codex.wordpress.org/Using_Permalinks

For performance reasons, it is not a good idea to start your permalink structure with the category, tag, author, or postname fields. The reason is that these are text fields, and using them at the beginning of your permalink structure it takes more time for WordPress to distinguish your Post URLs from Page URLs (which always use the text “page slug” as the URL), and to compensate, WordPress stores a lot of extra information in its database (so much that sites with lots of Pages have experienced difficulties).

So, it is best to have at least two path segments in your post’s permalink structure such as /%year%/%postname%/ or even /posts/%postname%/. (Some people recommend /%post_id%/%postname%/ which works for performance reasons but others recommend against it because it is unfriendly to users in the many contexts in which users interact with URLs.)

Very interesting indeed, everything I’ve read points to /%postname%/ for better SEO, what good is SEO if your site can’t be seen…

Let’s say you’re using a normal permalink string, like my preferred %year%/%postname%

Going to the link to Otto’s Technical writeup Otto’s technical writeup he even states this.

“I was not aware that other people didn’t know about this until recently, but since it seems to be little known, I thought I’d write a post on the topic.

In WordPress, you should never start the custom permalink string with any of these %postname%, %category%, %tag%, or %author%. (Unless you know what you’re doing, of course.)

Meaning that “%category%/%postname% ” is a bad custom permalink string. So is just “%postname%” for that matter. Why? Well, it has to do with how the WordPress Rewrite system works.”

Remember though if you do change your Permalink structure links that others have posted to your site on theirs wont work anymore, and back links are an important means of getting Pagerank with Google.

As I don’t promote this site actively I can get away with changing them now and besides I also need Google, Yahoo and Bing to revisit my site with their crawlers as I updated a lot of my posts SEO options with the plug-in All in One SEO Pack

A plug-in I use called XML Sitemap Generator for WordPress 3.2.4 creates a new XML Sitemap and also notifies Google, Bing and Yahoo that your site has been updated, you could also log into Google Webmaster Tools and upload the new XML Sitemap the above plug-in creates.

Another site I found for Sitemap creation is this one XML-Sitemaps.com they have a Sitemap generator feature that also produces an HTML Sitemap that you can then add to your site, there is a limit of 500 pages for the free online version.

Now to speed up my site which is another post.

Cheers

Aaron