The first time I tried to move a website from one web host to another it was a total disaster. The file transfer failed part of the way through because of a janky internet connection. I ended up completely trashing the website that I was trying to move. It was such a mess that I ended up scrapping the entire thing.
To be fair to my past self, the part about the internet connection wasn’t my fault. Where I really messed up was in how I handled my backups. I got files mixed up, ended up overwriting important configuration files, and basically ended up with a steaming pile of error pages.
Luckily, there was no great loss. The wrecked website was part of a personal project that I really should have given up long before anyway. At that time, I was years away from becoming the professional that I am now. I hardly had any idea what I was doing.
The experience stuck with me. My record migrating websites since then is undefeated.
The essential difference between what I do now compared to how I operated back then is that now I use a system. Systems are great. I use them whenever and wherever I can.
The biggest advantage of using a system is that once I learn how to do something, I never have to learn how to do it again. When I pick up a new piece of knowledge about something in the system, I adjust it accordingly. I’ve never found a need to scrap the whole system and start over.
If you have to move your site, then you need to have a plan
There are a lot of reasons that you might need to move your WordPress site to another web host. In my experience, it usually has to do with a trend of declining service. I’ve recently had to ditch my once fantastic host in favor of fresh pastures. Currently, I’m living the good life at Siteground and things are better than ever.
If you have to move your WordPress site to a new server, the first thing to check is if your new web host will provide that service. Some offer it for free for new accounts. Others might charge for it. The cost could be worth it if it means saving a headache.
The next option is to use a plugin. There are quite a few WordPress plugins like All-In-One WP Migration that can handle end-to-end migrations. I think that these plugins are a great option! I also think that it is incredibly important to know what to do if something goes wrong.
My aim in writing this guide to empower anyone who’s interested in learning how to perform a migration using the common tools found in most shared hosting accounts.
Moving or migrating a WordPress site from one hosting provider to another is a relatively easy task if done properly. One of the best ways to make sure something gets done properly is to use follow a guide.
Essentially, migrating WordPress from one host to another consists of four parts:
- backing up everything,
- moving the files,
- moving the database,
- and then making any needed reconfiguration in the new environment.
If you take the time to prepare before you get started and take the time to do it right, it’ll be less complicated than you might think.
1. Prepare the WordPress site that you want to move
This is a really important first step. While I was preparing this guide, I read a number of posts about WordPress migrations. None of the articles that I sampled included any advice to update and secure a site before preparing to move it.
I approach this step with a pragmatic outlook. I don’t want to spend the time moving anything that I don’t need. Migrating your site is a great time to do some Spring cleaning and fix anything that is broken.
Update WordPress and all third party plugins
Keeping your WordPress install and third party plugins up to date is the single best measure you can take to keep your site secure and malware free.
I prefer to always keep my WordPress sites and third party plugins up to date. I handle this WordPress updates for my own clients and I encourage everyone else to stay on top of them.
Out of date plugins are the most common way that hackers can exploit your site. Alone, they represent 55.9% of the entry points used by hackers. There are two plugins in particular that when out of date are taken advantage of the most. I’m looking at you RevSlider and you too Gravity Forms.
Clean up your site
You’re already getting ready to move your site. Now’s a great chance to clear out unused plugins and clean up your content.
- Remove images and files that aren’t attached to any pages or posts
- Fix broken links and set up redirects. Use a tool like W3C Link Checker.
- Review your plugins and installed themes. Delete any unused plugins. Remove all old themes except the most recent, default WordPress theme. The default them can come in handy if you need to test for conflicts.
Optimize your site’s database
Not everyone buys into this idea. I do.
Over time and with use, a WordPress database gets bloated with dozens if not hundreds of page and post revision and possibly thousands of spam comments. All of this extra data can add megabytes of unneeded data to an exported database file.
Use a plugin like WP-Optimize to clean up your database and keep it running smoothly.
Run a malware check of all WordPress directories
Now that your website is running as lean as it can be, you’ll want to minimize the chance that you have any corrupted files, plugins, or themes. Use an established security plugin like Wordfence or a service like Sucuri.
Checking for broken links, optimizing the database, and running security checks are all part of my regular website maintenance routine as well. If you’ve already made them part of your routine, then you’re probably sleeping better at night. You’ll also be one step ahead if you need to migrate your site to another host.
2. Backup and transfer WordPress files using your preferred FTP client (I use Filezilla)
Backup all files and folders in your WordPress directory
There are few options available for backing up and downloading your WordPress files. Read through them all and pick the one you prefer.
Option 1: Filezilla (or another FTP client)
Theoretically, you could make a fresh WordPress install on your new server and then copy over only the wp-content directory. However, if the WordPress versions between the old site and the new install don’t match you can run into trouble. If you’re using a caching plugin, you can run into problems there as well.
Save yourself a headache and copy over the entire directory where your WordPress site is installed.
There may be hidden files in your WordPress directory such as .htaccess. Make sure you’ve set your FTP client to display hidden files so that they get copied over too.
Copying all the files could really take some time. If your site has been around for a while and it’s been active, you might have hundreds of images. That’s a lot of data to download. After you start the transfer, you can go ahead and move on to the other steps while it’s working.
Option 2a: cPanel File Manager
You can also optionally use the File Manager tool in cPanel to create a .zip archive of the directories you want to move. Making an archive first will make the downloading part a lot faster if you have a larger site.
Option 2b: cPanel Partial Backup
cPanel also has an option to create a Partial Backup of the Home Directory. If you only have a single WordPress site installed in this directory, this can be an easy way to create and download a backup. If you have more than one site installed, then this file will be enormous so you’ll probably be better off with one of the other options.
Option 3: cPanel + Softaculous
cPanel and Softaculous, you may have the option to backup your WordPress installation with a single click. Then download the backup directly. This can be a great time saver for smaller sites.
A note about all the cPanel options:
Backups made with cPanel or Softaculous will be downloaded over HTTP. HTTP stands for Hypertext Transfer Protocol. This is the internet protocol used to serve web pages and other web content. It’s pretty great at that. However, it is much slower to download files over HTTP than if you use File Transfer Protocol (FTP).
You’ll really feel this difference if you don’t have a blazing fast internet connection and with larger files in the 2 or 3 GB range. Common file transfer applications like Filezilla connect to a remote server through FTP. For larger transfers and slower connections FTP is a better option.
3. Backup the WordPress Database
The second step is to move your database. (There’s nothing stopping you from reversing the order of Steps 2 and 3 and backing up the database first.)
First, export the database from your old hosting account. If it uses cPanel, the Backups page mentioned in Option 2b above will let you download a copy.
You can also use phpMyAdmin which is also available through cPanel.
If you go this way, select your database name from the left side menu. Then click “Export” in the top menu. If you have a pretty standard WordPress site then you won’t need anything other than the “Quick” setting. Click “Go” and save the exported file.
Once you’ve finished downloading the files and exporting the database, you can move on to the new hosting environment.
4. Set up a new WordPress site and database
Before you can migrate your backed up files and database to the new web host, you need to create a new environment for a WordPress install.
There are a few ways that you can go about this. Since most shared hosting and managed hosting accounts now offer cPanel, you’ll probably have access to the Softaculous installer.
You can use Softaculous to install a WordPress site in a few minutes. It will install the core WordPress files and create a new database.
These next steps will show that approach. I’m using cPanel and Softaculous in a Siteground hosting environment. If you have another web host, cPanel may look a little different but it should be close enough for you to follow along.
If you don’t have cPanel and Softaculous then you might have to do it the old fashioned way.
- Access cPanel in your new hosting account and find Softaculous. You can take a shortcut and just click WordPress since that’s where you want to go ultimately.
- Find and click Install Now beneath the description of WordPress.
- It’s really this simple. On the installation screen, you’ll be asked to supply the details of your new site.
This 1-click install will create a brand new WordPress site along with a new database. Depending on your web host, you may or may not have the option to set the new database name, user, and password.
If you do have the option to set those details, be sure to jot them down or take a screen shot. You’ll need this information later.
If you don’t have the option or forgot to copy the info, don’t worry. Head back into your FTP program and look at the newly installed files. In the folder where WordPress is installed, find wp-config.php.
Open this file with a text editor and look for the section that reads “MySQL settings – You can get this info from your web host”.
Either copy/paste this info into a new document or bake a backup of this file to reference later. One convention for backing up a file is to name the copy (which is actually the original) wp-config.php.bak.
5. Upload your site’s WordPress files to the new directory
Now that you have a fresh, new WordPress install, you can start uploading your backed up files.
Use your FTP program or cPanel’s file manager to view the directory where you just installed WordPress. Open your local directory where you saved your backed up WordPress site files. The two directories should look really similar in structure. Though since yours is from an established, active WordPress site, it probably has a lot more files in it.
Once you’re looking at both the local and remote directories, start copying over all the backed up files to the new web host. This will take some time depending on your internet connection speed. Upload speeds are pretty much always slower than download speeds.
You may see a dialog window pop up and ask if you want to overwrite the files in the destination directory. Choose “yes”.
Don’t delete these files from your local computer once the upload finishes. They are still needed until the final steps have been completed.
6. Edit the wp-config.php file in the new installation
Remember that info about the database that you were supposed to save earlier? Now you need it. In the directory where you installed WordPress, find and make a copy of wp-config.php.
Now open wp-config.php with whatever text editor you prefer (I use Sublime) and make these changes:
Change The Database Name
Locate the following line:
define(‘DB_NAME’, ‘db_name’);
The db_name portion of this line will currently be set to the MySQL database name for your old website. This must be changed to the name of the new database that you just created in the earlier step.
Change the Database Username
Below this you will find the line:
define(‘DB_USER’, ‘db_user’);
On this line, you need to change the db_user portion from the username for your old website to match the new database username you’ve just created.
Change The Database User Password
Finally, edit the third line:
define(‘DB_PASSWORD’, ‘db_pass’);
As with the others, the db_pass section of this line must be changed to the new secure password that was created for your MySQL user.
Save wp-config.php and close the file.
7. Import Your Database
Head back into cPanel on your new web host and click on phpMyAdmin. Locate your new database in the left side navigation menu and click on it.
Next, select the Import tab in the main navigation menu. Click “Choose File”. Locate and load the database file that you backed up earlier.
This file may take a little time to upload depending on its size. Pay attention to the max upload size indicated on this screen. If your file is larger than the max size allowed, you’ll have to use alternate means to import your file.
This will probably not be an issue. If it is, contact your web host and ask for assistance.
Extra: If you’re moving domains as well, you’ll have to update the imported database
When moving to a new domain you’ll need to update two settings in your freshly imported database.
While still in phpMyAdmin, on the left-hand side find the table called wp_options and click on it. The first two entries in this table are siteurl and home. If necessary update them to match your new domain name.
8. Buff and Polish
Broken link check
Check your website and make sure that your images are all loading and that internal links are working. This is quality control and it should be taken seriously. Go back to W3C Link Checker and check your links. Then check all your posts and pages to verify that your images are loading.
Changing domains
If you’re moving to a new domain, now is the time to make any DNS changes. This process is slightly different with every web host.
CDN updates
If you’re using a CDN like Cloudflare, you’ll need to update the DNS records to point at the IP address for your new host.
Conclusion
As you can see, when broken down into the above simple steps, the process isn’t that difficult. All it really requires is for you to be careful at each step and give yourself the option to go back to the original version until the last possible moment (in the case of any problems).
Have you migrated your WordPress website recently? Let me know your experience with the process in the comments section below!