Quantcast
Channel: The blog of whall » internal server error 500
Viewing all articles
Browse latest Browse all 2

WordPress upgrades and 1and1 hosting

$
0
0

I’ve hit my head against the virtual wall (whall?) more times than I can count over the past few years on something that I suddenly “fixed” recently, and I wanted to blog it for the masses.

In short,

If you’re running WordPress or any PHP-based application on a host that has both PHP 4.0 and 5.0 installed, append the following to your .htaccess file for that application:

Options All -Indexes
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

As an added bonus, I also detail how to upgrade MySQL 4.0 database to MySQL 5.0 on 1 & 1 hosting (see extended entry below).

I use 1 & 1 for my internet hosting, and have since, oh, 2003 or so. For the price I pay and the service I get, I’m very happy. There have been a few glitches, to be sure, and I’ve blogged about a few of them. But overall, I’ve been a happy camper.

I mention 1 & 1 because on all their shared hosting packages, they install both PHP 4.0 and 5.0. Ever since I can remember, I’ve had the dreaded “Internal Server Error 500″ on a few things on my blog, like exporting my blog to XML as a backup, or similar tasks. Sure, I can always do the manual MySQL backup because I’m a geek, but it annoyed me that I couldn’t do the XML backup. Also, some plugins just wouldn’t work right, and auto-upgrade almost NEVER worked.

This inability to auto-upgrade also frustrated some of the people I host blogs for. Yes, I host blogs. For those special few in my life (heh) I will set up, install, configure and host a wordpress blog so they don’t have to worry about it. I typically only have them pay for the domain name ($10 a year or so) and I host the site for free. I host more than a hundred domains, including personal blogs, commercial blogs, non-profit websites, and I use WordPress, Joomla, Drupal and even raw HTML (the shock and awe!), wherever appropriate. It’s not a money maker for me, and I only ask that if someone I host gets wildly popular and makes millions of dollars, that they kindly remember me on my birthday.

On every WordPress blog I hosted, the authors weren’t able to consistently install or update plugins, or perform the auto-update feature inside of WordPress. It would either give that infernal Internal Server Error 500 or it would just hang. So, they’d email me, I’d procrastinate, they’d nudge, I’d forget, they’d ask politely a fortieth time, I’d promise to do it, and then eventually I’d manually upgrade their plugins a year later.

I’m happy to say that the above .htaccess file changes have completely eradicated the auto-upgrade errors, and I can perform the XML backups all day long without a problem. Not only that, but my blog actually seems faster. In case you care, the .htaccess lines tell Apache (the web server running on the host) to use PHP 5.0 to process all the files ending in .php instead of the default of PHP 4.0.

I’d do a happy dance if there weren’t so many adoring fans surrounding me, restricting my movements.

For the big WordPress 2.9 upgrade that I’ve been putting off, I was also challenged by the fact that my personal blog as well as a few blogs I host used the older MySQL 4.0 databases instead of the newer MySQL 5.0 databases. WordPress 2.9 required a later version of 4.0 than 1 & 1 had installed, and I was wary of diving into the “upgrade MySQL 4.0 database to 5.0″ process.

Until last night.

The database upgrade went quite smoothly (this post was most helpful). In fact, I got it down to a science – take the values from the wp-config.php file (database name, username, and host name) and put it into the mysqldump / mysql commands to pull from the old 4.0 database and insert into the new 5.0 database.

My steps, for those interested and the inevitable Google searches that will land here, are documented in the extended version below.

Once I upgraded my MySQL Database to 5.0 and added the .htaccess lines at the top of the post, the WordPress 2.9 auto-upgrade was a cinch. Not only that, but several of the plugins that wouldn’t auto-update updated without issue. It was so easy and fun that I upgraded a few dozen blogs and their plugins as well.

Needless to say, I was quite pleased with myself. I’m celebrating by actually taking time to blog about it so you can be pleased with me, too!

If geekiness of this nature doesn’t please you, then maybe this Tom Tom Darth Vader behind the scenes video will.

Enjoy :)


MySQL upgrade from 4.0 to 5.0 at 1&1 (1and1)

For this, you need SSH access to your account. If you don’t have SSH access, then you’ll need PHPMyAdmin access and your compressed database size needs to be < 2MB, AND you’ll need to look elsewhere.

SSH into your host, and cd to wherever your blog is hosted. For a lot of people, this will be ~/ (home directory once you login). For me, since I host dozens of blogs, I create a directory for each blog and have all the WordPress files inside of there.

For this example, assume ~/blog is where the blog is hosted

First, use the 1&1 Control panel to create a new MySQL 5.0 database. This takes a couple minutes, so go ahead and get it started now.

When the DB creation process starts, it will give you four useful pieces of information:

  • Database name (db##########)
  • Database username (dbo#########)
  • Database password (random characters)
  • Database Hostname (db####.perfora.net)

Copy those off somewhere so you can use them later. Feel free to try to type them in by hand, but if you ask me, that’s just asking for trouble. Open up notepad or vi or your favorite text editor and copy off those 4 values.

You should note that the above values represent the NEW MySQL 5.0 database.

Now we need to find out what the OLD MySQL 4.0 database values are. Do the following:

(uiserver):~/blog >grep DB wp-config.php
define('DB_NAME', 'db1234567890');
define('DB_USER', 'dbo1234567890');
define('DB_PASSWORD', 'somepassword');
define('DB_HOST', 'db1234.perfora.net');

Now we have name, username, password and hostname of what your blog currently runs with.

We will first use the mysqldump command to make a backup of the 4.0 database and use the mysql command to populate the empty 5.0 database. You should take note that these commands are different by 4 characters.

First, the mysqldump command:

Template:
mysqldump -h (DB host) -u (DB user) -p (DB name) > ~/backupfile
(uiserver):~/blog > mysqldump -h db1234.perfora.net -u dbo1234567890 -p db1234567890 > ~/blogbackup-4.0-2010-05-06.sql
Enter password: <type in password here, not visible>

Note that I used the database values from the 4.0 database. -h means host, so we’re putting the DB host value right after it, -u means user, and -p means “ask for the password when running”. Don’t think that -p means “put the password on the command line”. I’m redirecting (with the > character) the database backup to a file in my home directory (~/) called blogbackup-4.0-2010-05-06.sql. I like putting dates on my backups, and I want to remember later that this was from a MySQL 4.0 database in case I need it later.

Once your new MySQL 5.0 database is ready (check your 1&1 Control Panel for status – it should say “ready” instead of “setup started”), you can now put your 4.0 database into it.

Note we’re using the mysql command, not mysqldump, even though the syntax is identical. Don’t forget to switch the redirection sign > to <, and don’t forget to use your new MySQL 5.0 database values!

Template:
mysql -h (DB host) -u (DB user) -p (DB name) < ~/backupfile
(uiserver):~/blog >
mysql -h db5678.perfora.net -u dbo9876543210 -p db9876543210 > ~/blogbackup-4.0-2010-05-06.sql
Enter password: <type in password here, not visible>

Please please please – don’t type this command with your old MySQL 4.0 database values. Use the NEW database you created.

Once that’s done, you edit your ~/blog/wp-config.php file and change the four lines of host, user, name and password to reflect your new MySQL 5.0 database values.

Your blog should work like it used to. If it doesn’t, you can always change your wp-config.php values back to your 4.0 values and retrace your steps to see what went wrong.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images