Hostgator

A few months ago I jumped on the GoDaddy bandwagon. Their prices were too enticing. $6.99 .com domains are hard to resist (not to mention $1.99 .info’s). I still use them exclusively as my registrar. The problem is I’m a creature of convenience. I didn’t want to fool with buying domains and hosting at two separate sites. Big mistake.

I was hosting 5 blogs (3 of them very active), as well as 2 BANS sites. I had two major issues. First of all, I couldn’t get wp-cache working. It turns out this is a known issue with Godaddy hosting, and nobody else can get it to work either. The other issue was that the BANS sites performance was horrendous. DB queries would take 30-60 seconds, and if they returned more than 100 or so items, the site would just fall over and spit out errors.

I put it off for several weeks, and tried to live with it, but I’d finally had enough. The BANS forums were raving about Hostgator, and their prices and features were great, so I jumped ship. (Yay cPanel!) I’m still using GoDaddy as my registrar, but all my hosting has switched over to Hostgator.

Luckily, I had switched hosting providers before, and basically knew the drill, but I’m writing this tutorial so people don’t make some of the same mistakes. Some of these steps may be different if you’re using other hosting providers, but the concepts are the same.

 

Step 1: Backup

If you’re running Wordpress, or just about any other blogging software, the main thing to remember is that you don’t just have to backup your files. The most important thing is to backup your database. Most major hosting providers make use of phpMyAdmin to interface with MySQL databases. Here’s a little checklist.

  • Backup your entire directory structure
  • Make sure to include "dotfiles", some FTP programs will hide any file that begins with a "." The most important one are .htaccess and .htpasswd (if you have password protected your site), but if you’re using shell access there may be others (.bashrc, .vimrc, emacs config files, etc).
  • Make sure your ftp program is keeping your permissions intact. I use Transmit and can’t say enough good things about it.
  • Export all your databases to files from phpMyAdmin

To get your db’s out of phpMyAdmin, just log in, and hit export. I would do them one at a time if you have multiple db’s as there is a bit of tweaking within each sql file you’re going to have to do to transfer them to your new host. Make sure you’re exporting in "SQL" format. Check "Save as file" otherwise, it’ll just backup the database locally (on the server). Hit go, and download the file. What you’ll have now is probably an enormous text file.  Save it for later. It wouldn’t be a bad idea to get into the habit of backing up your blog in this way on a regular basis.

Export your database

 

Step 2: Uploading to the new host

I’ll assume you’ve already signed up for your new hosting. I’ve been running on Hostgator for a couple weeks now, and performance is significantly better than it used to be with Godaddy. Plus wp-cache works perfectly without weird symlink-hacking. And db queries take no time at all, even on a large scale.

If you’re stuck with a crappy host, you can get a free month of Hostgator to give it a try (use the coupon code ICEISHOT). I’m running the Baby Croc plan. Unlimited domains, 100GB of space, 1000GB/mo bandwidth, unlimited databases, ssh, spamassassin, cPanel, and only $9.99 a month. I’m currently hosting all 5 blogs, and now 6 BANS sites, and I haven’t had a single issue.

If you’re using Wordpress there are a few things you need to do before you upload the files to the new host. First of all, you need to make a new database. If you’re using Hostgator, log into your site’s cPanel, and go to MySQL Databases. You need to create a new database. It will prefix the name of the db and user with whatever your username is. Just type in a name and hit create database.

Create a database

Now you’ll need a user to access it. Same thing. Type a username and password.

Add a new user

Now you need to give that user access to the database. Just find the user and db you just created in the drop down lists and click Add User to Database.

Give user db privileges

 

Now your database is created an ready for data. Now you have to edit your wp-config.php file. If your wordpress install was in the root directory, then so is this file, otherwise it’s wherever you put wordpress. Open it in an editor and change the values to the user/db you just created:

Change your wp-config.php

That’s all. Now you can upload your directory tree to the new server, and move on to the next step.

 

Step 3: Loading the new database with data

Remember that backup file you made from your old database? You’re just about ready to load the data into your new database.  There’s just one quick change. Open the file (should be something.sql) and find the line that looks something like this (should be line 15 or so):

CREATE DATABASE `your_db_name` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

You want to remove that whole line. You’ve already created the database, so this line would just cause havoc. Save the file, and get into phpMyAdmin on your new server. Select your database in the drop down menu on the left, and then click the import tab on the top right. Browse your drive for the SQL file, and hit go.

Import your database

Your database should have a ton of tables in it now. Your almost there. Now lets test it.

 

Step 4: Testing your new server

Now we don’t want to go live just yet. We need to test that we did everything right. To do this without changing the DNS of our domain (yet), we’re going to tell our local computer to point the domain at our new server. That way we can test it just like it’s live, but DNS everywhere else still points to your old server.

In Mac OS X and Linux, this is very easy to do. Just open up your /etc/hosts file. In windows the file is usually in

c:\windows\system32\drivers\etc\hosts

You may need to sudo to do this. On a Mac run the command:

sudo open /etc/hosts

You should have the file open in a text editor now. You’re going to want to add a line to point your domain name at the new server’s ip address. Add a line something like this.

23.4.5.678   yourdomain.com   www.yourdomain.com

Obviously, replace the ip with your new server’s ip, and "yourdomain.com" with your domain name in both places.

Save the file. You also have to flush DNS cache, which overrides /etc/hosts for some reason. Run this command:

Mac: sudo lookupd -flushcache

Windows: ipconfig /flushdns

Now point your browser at your domain. If it all worked, you should see your site just like it was on your old server.

 

Step 5: Changing DNS entries

That’s it. Now you can log into your registrar’s site, and point the domain at your new DNS servers. You should experience no downtime, as both servers are still up and running. After a few days, once it’s all propagated, you can cancel your old hosting account.

Have fun. It’s really not as bad as it looks, and if you’re suffering with a badly performing hosting service, it’s a necessity.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Facebook
  • TwitThis

Similar Posts