Header Shadow Image

WordPress: 500 Internal Server Error

So I received this 500 internal Server Error when trying to save my long posts on my WordPress 2.6.2.  In my case I have 1and1.com hosting and at first impressions, the problem appeared to be with MySQL and the time it took to save a post.  On top of this, my host doesn't allow access to the error_log files (HTTPD Error Log files) and only to the Access Log files (access_log) so I can't really see what the real issue is.  Here's how I solved the problem in my case:

I edited my .htaccess file in the root folder of my site to add this line to the end of it.  This directive tells the web server that files with .php extension should be handled by the PHP module:

"AddType x-mapp-php5 .php"

And the 500 Internal Server Error went away when I tried to save again.  For further digging into the 500 Internal Server error is to set the debug level in /etc/httpd/conf/httpd.conf file to debug, amongst other available settings, to get more details on where it is breaking:

# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
# LogLevel warn
LogLevel debug
After this, restart httpd (service httpd restart) to find out other details in the /var/www/http/error_log file which should point you further along.  Naturally, you may wish to disable this property otherwise the level of logging could, if there's substantial traffic, decrease the performance of your server.  If the error still occurs, isolate it by creating a plain .html file with NO tags at all:
localhost – – [28/Dec/2012:22:48:39 -0500] "GET /photos/gallery3/index.html HTTP/1.1" 200 38 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121120 Firefox/10.0.11 AlexaToolbar/alxf-2.17"
localhost – – [28/Dec/2012:22:48:46 -0500] "GET /photos/gallery3/index.php HTTP/1.1" 500 – "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121120 Firefox/10.0.11 AlexaToolbar/alxf-2.17"
# cat index.html
this is NOT an Html HELLO WORLD file.
If this page loads fine, then your folder permissions are fine (non 777) while directories can be 755, and checking the index.php file instead could be the next step.  Before we check any PHP files, first also check the php.ini in the local folder of your application.  Try to rename it and restart httpd.  If no effect, put it back and let's begin checking the index.php file:


# grep error_log /etc/php.ini
; server-specific log, STDERR, or a location specified by the error_log
; Set maximum length of log_errors. In error_log information about the source is
;error_log = php_errors.log
;error_log = syslog

If the error logging is disabled, as above, enable it to something like this (Add this line below the last error_log entry above so as to keep the original comments and texts intact in the original php.ini file): 

error_log = /var/log/httpd/php_errors.log

and restart the Apache HTTPD server as before (service httpd restart).  While doing this, first try a simple index.php script instead of the original index.php giving the error message:


Print "Hello, World!";

If this gives no error, it's likely a directive with the more comples index.php file you may have.  Use the original index.php file and try again this time relyling on the newly enabled php_errors.log file.  If you don't see anything, try adjusting this directive then restarting httpd:


If still nothing, try the error_reporting() function inside the code.  If one is there and is set to 0, set it to E_ALL:


// Report all PHP errors (see changelog)
If this works and gives you more information, check the messages last seen as this is likely where the issue is happening or in the statement right before.  And sure enough, we can see what the issue really is: an undefined function:

[Fri Dec 28 23:44:20 2012] [error] [client ::1] PHP Fatal error:  Call to undefined function mb_internal_encoding() in /var/www/html/photos/gallery3/system/core/Kohana.php on line 87

Sure enough, reading into the file, we see that the mbstring extension to PHP needs to be enabled:

// Set the default charset for mb_* functions

For that statement to work hence the 500 Internal Server error.  One can check further with the phpinfo(); function in a simple phpinfo.php file.  If the output has the below, then the multibyte support is disabled:

Zend Multibyte Support disabled 

and no other multibyte code present.  In some cases, you can install it with this command afer a quick yum search: yum install php-mbstring.x86_64.  Once installed, the following should be visible from phpinfo():


Multibyte Support enabled
Multibyte string engine libmbfl
HTTP input encoding translation disabled 

Another source of a 500 Internal Server error is a : (colon) instead of a ; (semicolon) at the end of a PHP statement like this:


This should really end in a ; (semicolon)  Try this if everything else didn't work.  
Another source of the error is if you have r-xr–r– permissions on you .htpasswd or .htaccess files.  Change these and see if it helps.

What's your 500 Internal Server error?  Post your adventure below. 🙂















Leave a Reply

You must be logged in to post a comment.

  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License