Moving WordPress to A New Host

You might have spotted a “moving notice” on the site recently, that vanished once the DNS updates pushed through.  This is because I finally have gotten started setting up on a new host and Eclectic Thoughts was the first of my sites to be moved (as it was the only one with no lingering ColdFusion elements) from my old host, HostNexus, to my new one, Vivio Technologies.

I worried a little about how hard it would be to move a WordPress site to a new host, but it turned out to pretty much be the same as moving a regular site, other than tweaking the WordPress config at the end.

Step 1 – Lock It Down

Put the live site in “down” mode (i.e. put up a site moving notice and set up an htaccess file to redirect everything to that).  I used a very simple HTML file with my sitedown notice and this basic .htaccess:

RewriteEngine On
RewriteBase /
RewriteRule .+\.xml$ /siteDown.html [L,NC,QSA,R]
RewriteRule .+\.htaccess$ /siteDown.html [L,NC,QSA,R]

RewriteCond %{REQUEST_URI} !^/siteDown.html$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/siteDown.html

ErrorDocument 400 /siteDown.html
ErrorDocument 401 /siteDown.html
ErrorDocument 403 /siteDown.html
ErrorDocument 404 /siteDown.html
ErrorDocument 500 /siteDown.html

Step 2 – Get the Files

Download ALL files from my current host – this is because WordPress auto updates and some plugins I update through the interface (some big ones I had to do manually because the server kept crashing on them, like JetPack), so my files were in a mixed state.

So downloading everything allowed me to be sure I had the current state of everything and all of my uploads.  I set up the download through FTP and left it for a hour or two and all done.

Step 3 – Get the Database

I logged in to Plesk (HostNexus’ admin) and then flipped to its phpMyAdmin to export my database.  HN doesn’t allow remove connections, so I couldn’t use MySQL Workbench.

It worked fine through phpMyAdmin, though if you have a super huge DB it might be more troublesome.  When doing this export, make sure to get structure and data, not just data!  Do not export it with user names attached or anything like that and skip the Create DB Schema option.

Step 4 – Set Things Up on the New Host

I then logged in to the cPanel for Vivio and spent some time setting up the FTP account, database, DB user name, etc.  This actually took me the longest, more because I’d never used cPanel before and had to occasionally Google or click around to figure stuff out.  Once everything seemed good, I uploaded all my files, I uploaded everything to the wrong directory at first. 😛

With the DB set up, I went into phpMyAdmin and imported the export from HN and then validated the resulting DB to be sure it was good.  I checked by having both admins open, checking counts, DB types were retained, table structure, and doing spot checks on the data.

Step 5 – Update WordPress

Last step, was setting up the wp-config.php file and modifying the DB settings to my new database name, user name, and password.  Upload that and all good to go.

Note: I didn’t change domains with this move, just moved to a new host.

Step 6 – Update DNS and Wait

Normally, you’d probably wait until you were done to do the DNS update, but I got most of it set up after submitting them, so it was just a matter of waiting for it to finish to test it (which is when I discovered I’d uploaded to the wrong folder LOL).

Mine took about 6 hours to change for me, but it may take 24-48 before most users are hitting the new site.  Obviously, I’ll be with HN awhile longer as well, as I have one client site to move which has one ColdFusion script I need to rewrite, and my other personal site An Eclectic World, which I obviously need to rewrite from ColdFusion first.