Moving WordPress to a new Domain name on DreamHost
If you plan on moving WordPress to a new Domain name on DreamHost there are a few things you need to know. In many ways the process is simple, but there can be a little “reading between the lines” necessary to avoid issues.
I recently moved my blog from one domain to another and documented the process I took to do so. Here is my story.
Acquiring a new Domain Name
In a recent post I described how I was able to get the best domain name for my blog – My name. After years of owning and using chaynie.com, I was able to get my hands on CraigHaynie.com and wanted to move my blog there.
Finding good instructions
There’s nothing better than a good set of clear instructions. Since I use DreamHost as my hosting provider I went looking for instructions specific to their system on how to make the change. By doing a quick Google Search I found this article on their site:
These instructions are pretty good – if you’re technical. I do have a pretty technical background so I thought “A lot of steps, but easy enough”. I put it off for several weeks but finally decided to tackle it a few days ago.
My Tips and Tricks
Here are the steps outlined in the instructions at the link I provided above. Below each step are my experiences and observations. Follow the DreamHost instructions above and use my comments as a supplement.
Step 1: Backup your data
I used FTP to download all the files from my old site using FileZilla (Standard, Not Pro). I SHOULD have logged in via SSH and zipped up the entire contents before downloading. It would have been a LOT faster.
An even better method would have been to zip up the site, copy the archive to the new hosting folder via SSH, and unzip there. That would require hosting on the same “user” within Dreamhost, which I did. This is way more technical however, and rather that researching all the linux commands I just did it the long way (FTP)
I used phpMyAdmin to backup the database. I knew I was going to have to use it to restore the data so I figured I may as well save time and go ahead and get logged in now.
This is one of those things where a little bit (more) technical aptitude can come in handy. phpMyAdmin is not exactly the most beautiful and intuitive user interface, but when you know what you are doing it is very effective.
I haven’t done anything with email yet. I will likely create a new email address at the new domain and set that up in Outlook. Once I do, I will phase over to the new email address a little at a time. Once done, I’ll add the old email as an alias to my new email address in the DreamHost panel.
Step 2: Add Hosting for the new site
Pretty straightforward. I just followed the instructions. It wasn’t explicit but the only thing you need to do other than set it up in DreamHost is change the NameServers on the domain wherever it is hosted to the DreamHost NameServers. The NameServer addresses will be presented right after you setup hosting on the DreamHost site.
Step 3: Create a new Database
I pretty much just followed the instructions. The only thing I will point out is that I did tell it to create a new user for the database that matched the name of the domain, just like how it was for the old domain. I did this instead of using the old db username so I didn’t later get confused and mess something up. I plan to kill off the old database, hosting, etc and would hate to accidentally torch something!
Step 4: Transfer your WordPress installation
WordPress Web Files
This is the step where you take all the files from your previous domain that you downloaded, and upload them to the new domain. Basically you are just putting them back just like they were, only in the new domain’s folder.
To make things faster when re-uploading, I did zip up the folder on my computer before FTPing back up to the new folder. Once there, I logged in via SSH and ran a command to unzip the archive (“unzip filename.zip”) and then deleted the archive (“rm -r filename.zip”). If you want to avoid adding additional technical components to the process, just avoid the zip/unzip process and upload using FTP.
Importing the Database
Before importing the database there is one necessary step that I didn’t see in the DreamHost instructions. You MUST edit the sql file you downloaded when “exporting” the database from your old domain, and change the references to the name of the new database. At the top of the file, change the “domainname_com” (in two places) to the new domain name and save the file before you import it. If you don’t, you’ll melt down the warp core (Well, actually, it just won’t work)
CREATE DATABASE IF NOT EXISTS `domainname_com` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
After making this change, you can “import” the database by logging into phpMyAdmin, navigating to the NEW database, and using the import function and choosing the file you just edited – as explained in the instructions.
Step 5: Edit the new wp-config.php file
I did this as explained in the instructions and it was pretty straight forward. I opened the file inside FileZilla (on the server side) and made the changes. When I saved and closed the file it asked if it should upload the saved version, and I said yes.
Step 6: Update the home and site url
I was able to use the WordPress interface to make these changes. After I did, I started clicking around in the admin and things started getting wonky on me, mostly because the links in the database were still pointing to the old site (See the next step). DO NOT MAKE CHANGES in the interface to anything else – you might be making them in the old site (old database) and not know it (Look at the address bar to see where you are). It’s best to follow the next step before making any changes
Step 7: Update all the URLs in the database
The instructions suggest using a plugin to make the url changes. What’s funny about that is you can’t install the plugin because the links in the database are not yet corrected and therefore keep sending you back to the old site when you try to install it.
When I realized that, I decided to use the command line method explained in the instructions since I was already logged in via SSH.
[server]$ wp search-replace http://example.com http://new.example.com
I ran this command TWO times … both with and without the www. since links were in the database both ways.
Success! Or so I thought.
It works! Beautiful!
Then, I clicked one of the links to a blog post. I got a 404 error. EEK!!
Thank goodness for the following blog post I found on Google. It was exactly what I needed to do and worked flawlessly.
I also had to go reconfigure Yoast SEO, setup the new domain in Google Webmaster Tools, etc. I removed the physical hosting on the old domain and switched to a “forward only” pointed at the new domain. That way any links that exist in the wild will still work. I am sure there are things I have forgotten but for now everything seems to be hunky-dory.
THIS IS NOT FOR THE FAINT OF HEART!
Yea, I am technical – but in order to get all this done I had to dig some things from deep, deep, deep in memory.
Setting up the new domain hosting on DreamHost, pointing the domain to the hosting, and setting up the new database are not that hard. What’s not quite as easy (or, even difficult) is using SSH, FTP, phpMyAdmin, and editing config files. Not the end of the world, but requires patience and technical aptitude. As it all started coming back to me I was fine, and enjoyed the trip down technical memory lane. Well, all except the part where I got stuck in the VI editor for a minute and had to google my way out of it – [esc] q! [enter] !!!
If you are technical, go for it. If not, forget about it … hire someone!