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:
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:
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:
[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
mb_internal_encoding(Kohana::CHARSET);
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():
mbstring
Another source of a 500 Internal Server error is a : (colon) instead of a ; (semicolon) at the end of a PHP statement like this:
What's your 500 Internal Server error? Post your adventure below. 🙂
Cheers!
TK.